mirror of
https://2025-dev.shylinux.com/x/20250215-cluster
synced 2025-04-25 05:08:06 +08:00
opt some
This commit is contained in:
parent
8419bfdd9c
commit
61136b7f0c
@ -5,31 +5,58 @@ import (
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/task"
|
||||
)
|
||||
|
||||
type travel struct {
|
||||
list string `name:"list list" help:"遍历"`
|
||||
ice.Space
|
||||
list string `name:"list space auto" help:"集群管理"`
|
||||
foreach string `name:"foreach" help:"遍历" icon:"bi bi-card-list"`
|
||||
}
|
||||
|
||||
func (s travel) List(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.SPACE, ice.OPS, web.DREAM, web.SERVER).Table(func(value ice.Maps) {
|
||||
if len(arg) == 0 {
|
||||
m.PushRecord(value, "time,name,module,version")
|
||||
} else {
|
||||
switch value[nfs.MODULE] {
|
||||
case "2025-dev.shylinux.com/x/20250215-cluster":
|
||||
m.Cmdy(web.SPACE, value[mdb.NAME], m.PrefixKey(), arg).RewriteAppend(func(val, key string, index int) string {
|
||||
kit.If(key == web.SPACE, func() { val = kit.Keys(value[mdb.NAME], val) })
|
||||
return val
|
||||
})
|
||||
case arg[0]:
|
||||
m.Cmd(web.SPACE, value[mdb.NAME], arg[1:]).Table(func(val ice.Maps, index int, head []string) {
|
||||
m.Push(web.SPACE, value[mdb.NAME]).PushRecord(val, head...)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
if len(arg) == 0 {
|
||||
m.Push(nfs.VERSION, ice.Info.Make.Version)
|
||||
m.Push(mdb.TIME, ice.Info.Make.Time)
|
||||
m.Cmdy(code.PUBLISH, nfs.BINARY)
|
||||
m.Action(s.Foreach)
|
||||
} else {
|
||||
m.Cmdy(web.SPACE, arg[0], m.PrefixKey())
|
||||
}
|
||||
}
|
||||
func (s travel) Foreach(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s, s.Concurrent, ice.Info.Make.Module, m.PrefixKey()).PushAction(s.BinaryActionList(m)...).Action(s.Foreach, s.Upgrade)
|
||||
}
|
||||
func (s travel) Upgrade(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s, s.Sequential, ice.Info.Make.Module, code.UPGRADE).Action(s.Foreach)
|
||||
}
|
||||
func (s travel) Concurrent(m *ice.Message, arg ...string) {
|
||||
m.SpaceListServer().TableGo(func(value ice.Maps, lock *task.Lock) { s.pushRecord(m, value, arg...) })
|
||||
}
|
||||
func (s travel) Sequential(m *ice.Message, arg ...string) {
|
||||
m.SpaceListServer().Table(func(value ice.Maps) { s.pushRecord(m, value, arg...) })
|
||||
}
|
||||
func (s travel) pushRecord(m *ice.Message, value ice.Maps, arg ...string) {
|
||||
if value[nfs.MODULE] == arg[0] {
|
||||
m.Cmd(web.SPACE, value[mdb.NAME], arg[1:]).Table(func(val ice.Maps, index int, head []string) {
|
||||
m.Push(web.SPACE, value[mdb.NAME]).PushRecord(val, head...)
|
||||
})
|
||||
}
|
||||
if value[nfs.MODULE] == "2025-dev.shylinux.com/x/20250215-cluster" {
|
||||
m.Copy(m.Cmd(web.SPACE, value[mdb.NAME], m.PrefixKey(), m.ActionKey(), arg).RewriteAppend(func(val, key string, index int) string {
|
||||
kit.If(key == web.SPACE, func() { val = kit.Keys(value[mdb.NAME], val) })
|
||||
return val
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.chat.dev.cluster.travel", travel{}) }
|
||||
|
||||
type Travel struct {
|
||||
travel
|
||||
foreach string `name:"foreach" help:"遍历" icon:"bi bi-card-list"`
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.chat.dev.cluster.travel", Travel{}) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user