diff --git a/go.mod b/go.mod index b53b80d..d699cd9 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module 2025-dev.shylinux.com/x/20250215-cluster go 1.13 require ( - shylinux.com/x/ice v1.5.70 - shylinux.com/x/icebergs v1.9.71 - shylinux.com/x/toolkits v1.0.18 + shylinux.com/x/ice v1.5.71 + shylinux.com/x/icebergs v1.9.72 + shylinux.com/x/toolkits v1.0.19 ) diff --git a/go.sum b/go.sum index cf6aa4d..b2805de 100644 --- a/go.sum +++ b/go.sum @@ -4,10 +4,16 @@ shylinux.com/x/go-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U= shylinux.com/x/go-qrcode v0.0.3/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po= shylinux.com/x/ice v1.5.70 h1:fIv86pk535PnwRVhKFkIDvV0xh2SUdL34FmCnjGDBgg= shylinux.com/x/ice v1.5.70/go.mod h1:gZLXlXi58yWdW0HP3c4K/IFS8my43DId6ke3vvXiq1k= +shylinux.com/x/ice v1.5.71 h1:5yrs+9uj3xNjsQuuLed/3lfF10syjbHhUT8LJAJqClo= +shylinux.com/x/ice v1.5.71/go.mod h1:2KKKi+Jridkkg+NWUrSX9S7Pe5zuwihBaVJ0nNY/FmY= shylinux.com/x/icebergs v1.9.71 h1:h31b/MsEXinqDiVygbCLdiFVDLEhNpiwD4Q+U2tg/iU= shylinux.com/x/icebergs v1.9.71/go.mod h1:+4bl7yJRMFtlTQRDLd+xh6b0hwXkqWaHLmx63Jeewwk= +shylinux.com/x/icebergs v1.9.72 h1:y3oVuMZtsI6hX0HLdfgzeDZNSbyoLrVSWl81JQcV+fA= +shylinux.com/x/icebergs v1.9.72/go.mod h1:3Bdp3tjzw+hUKJF+kR8pfsrbjAf72DVZmCaE8/MPFtk= shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q= shylinux.com/x/toolkits v1.0.18 h1:jtQZhmvU10Ajegc87tU0cYFUBSviaODo5TsCXpYb2O4= shylinux.com/x/toolkits v1.0.18/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q= +shylinux.com/x/toolkits v1.0.19 h1:Nrx0xYRc5ph1WS66EZ1hJUCe+2FdSWQ4QP6tBlguikQ= +shylinux.com/x/toolkits v1.0.19/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q= shylinux.com/x/websocket v0.0.4 h1:AJpwblePoOpiE6C8NrvgNYpKTotXMLrDDX2chTvx44Q= shylinux.com/x/websocket v0.0.4/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw= diff --git a/src/travel/travel.go b/src/travel/travel.go index 4c93407..96c9369 100644 --- a/src/travel/travel.go +++ b/src/travel/travel.go @@ -14,14 +14,19 @@ import ( "shylinux.com/x/toolkits/task" ) -type travel struct { +type Travel struct { ice.Space - script string `name:"create name*=2025-cluster port*=40000 count*=3" icon:"bi bi-terminal"` - list string `name:"list space auto" help:"集群管理"` + weight string `name:"weight" help:"统计" icon:"bi bi-pie-chart"` foreach string `name:"foreach" help:"遍历" icon:"bi bi-card-list"` + script string `name:"create name*=2025-cluster port*=40000 count*=3" icon:"bi bi-terminal"` + upgrade string `name:"upgrade space"` + list string `name:"list space auto" help:"集群管理"` } -func (s travel) Script(m *ice.Message, arg ...string) { +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, s.Publish) +} +func (s Travel) Script(m *ice.Message, arg ...string) { for i := 0; i < kit.Int(m.Option(mdb.COUNT)); i++ { m.Option(cli.CTX_ENV, cli.CTX_NAME, m.Option(mdb.NAME)+kit.Format(i)) m.Option(cli.CTX_ARG, kit.JoinCmdArgs(ice.DEV, m.Option(ice.MSG_USERHOST), tcp.NODENAME, m.Option(mdb.NAME)+kit.Format(i), tcp.PORT, kit.Format(kit.Int(m.Option(tcp.PORT))+i))) @@ -29,7 +34,17 @@ func (s travel) Script(m *ice.Message, arg ...string) { } m.Action(s.Foreach, s.Script) } -func (s travel) List(m *ice.Message, arg ...string) { +func (s Travel) Publish(m *ice.Message, arg ...string) { + m.Cmdy(web.SPACE, ice.OPS, web.DREAM, code.PUBLISH, m.Option(ice.MSG_USERPOD)) +} +func (s Travel) Upgrade(m *ice.Message, arg ...string) { + if m.Option(web.SPACE) != "" { + m.Cmd(web.SPACE, m.Option(web.SPACE), code.UPGRADE) + return + } + m.Cmdy(s, s.Sequential, ice.Info.Make.Module, code.UPGRADE).Action(s.Foreach) +} +func (s Travel) List(m *ice.Message, arg ...string) { if len(arg) == 0 { stat := map[string]int{} m.SpaceListServer().Table(func(value ice.Maps) { stat[value[nfs.MODULE]]++ }) @@ -46,21 +61,18 @@ func (s travel) List(m *ice.Message, arg ...string) { 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) { + +func init() { ice.Cmd("web.chat.dev.cluster.travel", Travel{}) } + +func (s Travel) Concurrent(m *ice.Message, arg ...string) { m.SpaceListServer().TableGo(func(value ice.Maps, lock *task.Lock) { s.pushRecord(m, value, arg...) }) m.SortStrR(web.SPACE) } -func (s travel) Sequential(m *ice.Message, arg ...string) { +func (s Travel) Sequential(m *ice.Message, arg ...string) { m.SpaceListServer().Table(func(value ice.Maps) { s.pushRecord(m, value, arg...) }) m.SortStrR(web.SPACE) } -func (s travel) pushRecord(m *ice.Message, value ice.Maps, arg ...string) { +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...) @@ -73,12 +85,3 @@ func (s travel) pushRecord(m *ice.Message, value ice.Maps, arg ...string) { })) } } - -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{}) }