forked from x/icebergs
opt mdb
This commit is contained in:
parent
aacb485deb
commit
244dab2e4b
@ -6,6 +6,4 @@ import (
|
||||
|
||||
const ENGINE = "engine"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{ENGINE: {Help: "引擎", Actions: RenderAction()}})
|
||||
}
|
||||
func init() { Index.MergeCommands(ice.Commands{ENGINE: {Help: "引擎", Actions: RenderAction()}}) }
|
||||
|
@ -34,9 +34,6 @@ func _hash_insert(m *ice.Message, prefix, chain string, arg ...string) string {
|
||||
if expire := m.Conf(prefix, kit.Keys(chain, kit.Keym(EXPIRE))); expire != "" {
|
||||
arg = kit.Simple(TIME, m.Time(expire), arg)
|
||||
}
|
||||
m.Debug("what %v %v", m.Conf(prefix, chain))
|
||||
m.Debug("what %v %v", kit.Data())
|
||||
m.Debug("what %v %v", m.Conf(prefix, chain))
|
||||
return m.Echo(Rich(m, prefix, chain, kit.Data(arg, TARGET, m.Optionv(TARGET)))).Result()
|
||||
}
|
||||
func _hash_delete(m *ice.Message, prefix, chain, field, value string) {
|
||||
@ -75,8 +72,8 @@ func _hash_select_field(m *ice.Message, prefix, chain string, key string, field
|
||||
return
|
||||
}
|
||||
func _hash_prunes(m *ice.Message, prefix, chain string, arg ...string) {
|
||||
defer RLock(m, prefix, chain)()
|
||||
fields := _hash_fields(m)
|
||||
defer RLock(m, prefix, chain)()
|
||||
Richs(m, prefix, chain, FOREACH, func(key string, value Map) {
|
||||
switch value = kit.GetMeta(value); cb := m.OptionCB(PRUNES).(type) {
|
||||
case func(string, Map) bool:
|
||||
@ -93,18 +90,19 @@ func _hash_prunes(m *ice.Message, prefix, chain string, arg ...string) {
|
||||
})
|
||||
}
|
||||
func _hash_export(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
f, p, e := miss.CreateFile(kit.Keys(file, JSON))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
defer m.Echo(p)
|
||||
m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p)
|
||||
m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, len(m.Confm(prefix, kit.Keys(chain, HASH))))
|
||||
en := json.NewEncoder(f)
|
||||
defer Lock(m, prefix, chain)()
|
||||
if en.SetIndent("", " "); !m.Warn(en.Encode(m.Confv(prefix, kit.Keys(chain, HASH))), EXPORT, prefix) {
|
||||
m.Conf(prefix, kit.Keys(chain, HASH), "")
|
||||
}
|
||||
}
|
||||
func _hash_import(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
f, e := miss.OpenFile(kit.Keys(file, JSON))
|
||||
if m.Warn(e) {
|
||||
return
|
||||
@ -114,7 +112,6 @@ func _hash_import(m *ice.Message, prefix, chain, file string) {
|
||||
m.Assert(json.NewDecoder(f).Decode(&list))
|
||||
m.Logs(IMPORT, KEY, path.Join(prefix, chain), FILE, kit.Keys(file, JSON), COUNT, len(list))
|
||||
defer m.Echo("%d", len(list))
|
||||
defer Lock(m, prefix, chain)()
|
||||
for k, data := range list {
|
||||
if m.Confv(prefix, kit.Keys(chain, HASH, k)) == nil {
|
||||
m.Confv(prefix, kit.Keys(chain, HASH, k), data)
|
||||
@ -155,9 +152,7 @@ func HashKey(m *ice.Message) string {
|
||||
}
|
||||
return HashShort(m)
|
||||
}
|
||||
func HashShort(m *ice.Message) string {
|
||||
return kit.Select(HASH, m.Config(SHORT), m.Config(SHORT) != UNIQ)
|
||||
}
|
||||
func HashShort(m *ice.Message) string { return kit.Select(HASH, m.Config(SHORT), m.Config(SHORT) != UNIQ) }
|
||||
func HashField(m *ice.Message) string { return kit.Select(HASH_FIELD, m.Config(FIELD)) }
|
||||
func HashInputs(m *ice.Message, arg ...Any) *ice.Message {
|
||||
return m.Cmdy(INPUTS, m.PrefixKey(), "", HASH, arg)
|
||||
@ -184,7 +179,7 @@ func HashModify(m *ice.Message, arg ...Any) *ice.Message {
|
||||
}
|
||||
func HashSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
if len(arg) > 0 && arg[0] == FOREACH {
|
||||
m.Fields(0, HashField(m))
|
||||
m.OptionFields(HashField(m))
|
||||
} else {
|
||||
m.Fields(len(kit.Slice(arg, 0, 1)), HashField(m))
|
||||
}
|
||||
@ -200,10 +195,7 @@ func HashPrunes(m *ice.Message, cb func(Map) bool) *ice.Message {
|
||||
if kit.Format(value[TIME]) > expire {
|
||||
return false
|
||||
}
|
||||
if cb != nil && !cb(value) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return cb == nil || cb(value)
|
||||
})
|
||||
return m.Cmdy(PRUNES, m.PrefixKey(), "", HASH).StatusTimeCount()
|
||||
}
|
||||
@ -241,33 +233,34 @@ func HashSelectDetail(m *ice.Message, key string, cb Any) (has bool) {
|
||||
return
|
||||
}
|
||||
func HashSelectField(m *ice.Message, key string, field string) (value string) {
|
||||
HashSelectDetail(m, key, func(h string, val ice.Map) {
|
||||
HashSelectDetail(m, key, func(key string, val ice.Map) {
|
||||
if field == HASH {
|
||||
value = h
|
||||
value = key
|
||||
} else {
|
||||
value = kit.Format(val[field])
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
func HashTarget(m *ice.Message, h string, add Any) (p Any) {
|
||||
HashSelectUpdate(m, h, func(value ice.Map) {
|
||||
p = value[TARGET]
|
||||
if pp, ok := p.(Map); ok && len(pp) == 0 {
|
||||
p = nil
|
||||
func HashSelectTarget(m *ice.Message, key string, create Any) (target Any) {
|
||||
HashSelectUpdate(m, key, func(value ice.Map) {
|
||||
target = value[TARGET]
|
||||
if _target, ok := target.(Map); ok && len(_target) == 0 {
|
||||
target = nil
|
||||
}
|
||||
if p == nil && add != nil {
|
||||
switch add := add.(type) {
|
||||
case func(ice.Map) ice.Any:
|
||||
p = add(value)
|
||||
case func() ice.Any:
|
||||
p = add()
|
||||
default:
|
||||
m.ErrorNotImplement(p)
|
||||
return
|
||||
}
|
||||
value[TARGET] = p
|
||||
if target != nil || create == nil {
|
||||
return
|
||||
}
|
||||
switch create := create.(type) {
|
||||
case func(ice.Map) ice.Any:
|
||||
target = create(value)
|
||||
case func() ice.Any:
|
||||
target = create()
|
||||
default:
|
||||
m.ErrorNotImplement(create)
|
||||
return
|
||||
}
|
||||
value[TARGET] = target
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -23,14 +23,13 @@ func _list_inputs(m *ice.Message, prefix, chain string, field, value string) {
|
||||
m.SortIntR(COUNT)
|
||||
}()
|
||||
defer RLock(m, prefix, chain)()
|
||||
m.Debug("what %v %v", prefix, chain)
|
||||
Grows(m, prefix, chain, "", "", func(value ice.Map) {
|
||||
value = kit.GetMeta(value)
|
||||
list[kit.Format(value[field])] += kit.Int(kit.Select("1", value[COUNT]))
|
||||
})
|
||||
}
|
||||
func _list_insert(m *ice.Message, prefix, chain string, arg ...string) {
|
||||
m.Logs(INSERT, KEY, path.Join(prefix, chain), arg[0], arg[1])
|
||||
m.Logs(INSERT, KEY, path.Join(prefix, chain), arg)
|
||||
defer Lock(m, prefix, chain)()
|
||||
m.Echo("%d", Grow(m, prefix, chain, kit.Dict(arg, TARGET, m.Optionv(TARGET))))
|
||||
}
|
||||
@ -47,13 +46,13 @@ func _list_select(m *ice.Message, prefix, chain, field, value string) {
|
||||
})
|
||||
}
|
||||
func _list_export(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
f, p, e := miss.CreateFile(kit.Keys(file, CSV))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
defer m.Echo(p)
|
||||
w := csv.NewWriter(f)
|
||||
defer w.Flush()
|
||||
defer RLock(m, prefix, chain)()
|
||||
count, head := 0, kit.Split(ListField(m))
|
||||
Grows(m, prefix, chain, "", "", func(index int, value ice.Map) {
|
||||
if value = kit.GetMeta(value); index == 0 {
|
||||
@ -62,11 +61,7 @@ func _list_export(m *ice.Message, prefix, chain, file string) {
|
||||
}
|
||||
w.Write(head)
|
||||
}
|
||||
data := []string{}
|
||||
for _, k := range head {
|
||||
data = append(data, kit.Format(value[k]))
|
||||
}
|
||||
w.Write(data)
|
||||
w.Write(kit.Simple(head, func(k string) string { return kit.Format(value[k]) }))
|
||||
count++
|
||||
})
|
||||
m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, count)
|
||||
@ -74,13 +69,13 @@ func _list_export(m *ice.Message, prefix, chain, file string) {
|
||||
m.Conf(prefix, kit.Keys(chain, LIST), "")
|
||||
}
|
||||
func _list_import(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
f, e := miss.OpenFile(kit.Keys(file, CSV))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
r := csv.NewReader(f)
|
||||
head, _ := r.Read()
|
||||
count := 0
|
||||
defer RLock(m, prefix, chain)()
|
||||
for {
|
||||
line, e := r.Read()
|
||||
if e != nil {
|
||||
@ -97,7 +92,7 @@ func _list_import(m *ice.Message, prefix, chain, file string) {
|
||||
Grow(m, prefix, chain, data)
|
||||
count++
|
||||
}
|
||||
m.Logs(IMPORT, KEY, kit.Keys(prefix, chain), COUNT, count)
|
||||
m.Logs(IMPORT, KEY, kit.Keys(prefix, chain), FILE, kit.Keys(file, CSV), COUNT, count)
|
||||
m.Echo("%d", count)
|
||||
}
|
||||
|
||||
@ -120,30 +115,44 @@ func ListAction(arg ...ice.Any) ice.Actions {
|
||||
}
|
||||
func PageListAction(arg ...ice.Any) ice.Actions {
|
||||
return ice.MergeActions(ice.Actions{
|
||||
SELECT: {Name: "select id auto insert page", Hand: func(m *ice.Message, arg ...string) { ListSelect(m, arg...) }},
|
||||
NEXT: {Hand: func(m *ice.Message, arg ...string) { NextPageLimit(m, m.Config(COUNT), kit.Slice(arg, 1)...) }},
|
||||
PREV: {Hand: func(m *ice.Message, arg ...string) { PrevPage(m, m.Config(COUNT), kit.Slice(arg, 1)...) }},
|
||||
SELECT: {Name: "select id auto insert page", Hand: func(m *ice.Message, arg ...string) { PageListSelect(m, arg...) }},
|
||||
NEXT: {Hand: func(m *ice.Message, arg ...string) { NextPage(m, m.Config(COUNT), kit.Slice(arg, 1)...) }},
|
||||
PREV: {Hand: func(m *ice.Message, arg ...string) { PrevPageLimit(m, m.Config(COUNT), kit.Slice(arg, 1)...) }},
|
||||
}, ListAction(arg...))
|
||||
}
|
||||
func ListField(m *ice.Message) string { return kit.Select(LIST_FIELD, m.Config(FIELD)) }
|
||||
func ListSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
OptionPage(m, kit.Slice(arg, 1)...)
|
||||
m.Fields(len(kit.Slice(arg, 0, 1)), ListField(m))
|
||||
if m.Cmdy(SELECT, m.PrefixKey(), "", LIST, ID, arg); !m.FieldsIsDetail() {
|
||||
m.SortIntR(ID)
|
||||
return m.StatusTimeCountTotal(m.Config(COUNT))
|
||||
}
|
||||
return m.StatusTime()
|
||||
}
|
||||
func PrevPageLimit(m *ice.Message, total string, arg ...string) {
|
||||
func PageListSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
OptionPage(m, kit.Slice(arg, 1)...)
|
||||
return ListSelect(m, arg...)
|
||||
}
|
||||
func NextPageLimit(m *ice.Message, total string, arg ...string) {
|
||||
if kit.Int(kit.Select("0", arg, 1)) > 0 {
|
||||
PrevPage(m, total, arg...)
|
||||
NextPage(m, total, arg...)
|
||||
} else {
|
||||
m.ProcessHold("已经最前一页啦!")
|
||||
m.ProcessHold("已经是最后一页啦!")
|
||||
}
|
||||
}
|
||||
func NextPage(m *ice.Message, total string, arg ...string) {
|
||||
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||
if offends := kit.Int(offend) - kit.Int(limit); total != "0" && (offends <= -kit.Int(total) || offends >= kit.Int(total)) {
|
||||
m.ProcessHold("已经是最后一页啦!")
|
||||
} else if offends == 0 {
|
||||
m.ProcessRewrite("offend", "")
|
||||
} else {
|
||||
m.ProcessRewrite("offend", offends)
|
||||
}
|
||||
}
|
||||
func PrevPage(m *ice.Message, total string, arg ...string) {
|
||||
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||
if offends := kit.Int(offend) - kit.Int(limit); total != "0" && (offends <= -kit.Int(total) || offends >= kit.Int(total)) {
|
||||
if offends := kit.Int(offend) + kit.Int(limit); total != "0" && (offends <= -kit.Int(total) || offends >= kit.Int(total)) {
|
||||
m.ProcessHold("已经是最前一页啦!")
|
||||
} else if offends == 0 {
|
||||
m.ProcessRewrite("offend", "")
|
||||
@ -151,21 +160,11 @@ func PrevPage(m *ice.Message, total string, arg ...string) {
|
||||
m.ProcessRewrite("offend", offends)
|
||||
}
|
||||
}
|
||||
func NextPage(m *ice.Message, total string, arg ...string) {
|
||||
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||
if offends := kit.Int(offend) + kit.Int(limit); total != "0" && (offends <= -kit.Int(total) || offends >= kit.Int(total)) {
|
||||
m.ProcessHold("已经是最后一页啦!")
|
||||
} else if offends == 0 {
|
||||
m.ProcessRewrite("offend", "")
|
||||
} else {
|
||||
m.ProcessRewrite("offend", offends)
|
||||
}
|
||||
}
|
||||
func NextPageLimit(m *ice.Message, total string, arg ...string) {
|
||||
func PrevPageLimit(m *ice.Message, total string, arg ...string) {
|
||||
if kit.Int(kit.Select("0", arg, 1)) < 0 {
|
||||
NextPage(m, total, arg...)
|
||||
PrevPage(m, total, arg...)
|
||||
} else {
|
||||
m.ProcessHold("已经是最后一页啦!")
|
||||
m.ProcessHold("已经是最前一页啦!")
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,14 +193,6 @@ const (
|
||||
CACHE_FIELD = "cache.field"
|
||||
)
|
||||
|
||||
func Grow(m *ice.Message, prefix string, chain Any, data Any) int {
|
||||
cache := m.Confm(prefix, chain)
|
||||
if cache == nil {
|
||||
cache = kit.Data()
|
||||
m.Confv(prefix, chain, cache)
|
||||
}
|
||||
return miss.Grow(path.Join(prefix, kit.Keys(chain)), cache, data)
|
||||
}
|
||||
func Grows(m *ice.Message, prefix string, chain Any, match string, value string, cb Any) Map {
|
||||
cache := m.Confm(prefix, chain)
|
||||
if cache == nil {
|
||||
@ -221,3 +212,11 @@ func Grows(m *ice.Message, prefix string, chain Any, match string, value string,
|
||||
kit.Int(kit.Select("10", m.Option(CACHE_LIMIT))),
|
||||
match, value, cb)
|
||||
}
|
||||
func Grow(m *ice.Message, prefix string, chain Any, data Any) int {
|
||||
cache := m.Confm(prefix, chain)
|
||||
if cache == nil {
|
||||
cache = kit.Data()
|
||||
m.Confv(prefix, chain, cache)
|
||||
}
|
||||
return miss.Grow(path.Join(prefix, kit.Keys(chain)), cache, data)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/logs"
|
||||
"shylinux.com/x/toolkits/task"
|
||||
)
|
||||
|
||||
@ -248,7 +249,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
|
||||
}}
|
||||
|
||||
func init() {
|
||||
ice.Index.Register(Index, nil, INSERT, DELETE, MODIFY, SELECT, INPUTS, PRUNES, EXPORT, IMPORT, PLUGIN, ENGINE, RENDER, SEARCH)
|
||||
ice.Index.Register(Index, nil, INSERT, DELETE, MODIFY, SELECT, INPUTS, PRUNES, EXPORT, IMPORT, PLUGIN, RENDER, ENGINE, SEARCH)
|
||||
}
|
||||
func AutoConfig(args ...ice.Any) *ice.Action {
|
||||
return &ice.Action{Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -19,7 +19,6 @@ func _zone_inputs(m *ice.Message, prefix, chain, zone string, field, value strin
|
||||
return
|
||||
}
|
||||
h := _hash_select_field(m, prefix, chain, zone, HASH)
|
||||
defer Lock(m, prefix, chain)()
|
||||
_list_inputs(m, prefix, kit.Keys(chain, HASH, h), field, value)
|
||||
}
|
||||
func _zone_insert(m *ice.Message, prefix, chain, zone string, arg ...string) {
|
||||
@ -28,21 +27,18 @@ func _zone_insert(m *ice.Message, prefix, chain, zone string, arg ...string) {
|
||||
h = _hash_insert(m, prefix, chain, _mdb_getmeta(m, prefix, chain, SHORT), zone)
|
||||
}
|
||||
m.Assert(h != "")
|
||||
defer Lock(m, prefix, chain)()
|
||||
_list_insert(m, prefix, kit.Keys(chain, HASH, h), arg...)
|
||||
}
|
||||
func _zone_modify(m *ice.Message, prefix, chain, zone, id string, arg ...string) {
|
||||
h := _hash_select_field(m, prefix, chain, zone, HASH)
|
||||
m.Assert(h != "")
|
||||
defer RLock(m, prefix, chain)()
|
||||
_list_modify(m, prefix, kit.Keys(chain, HASH, h), ID, id, arg...)
|
||||
}
|
||||
func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
|
||||
if zone == "" {
|
||||
_hash_select(m, prefix, chain, HASH, FOREACH)
|
||||
return
|
||||
}
|
||||
if zone == RANDOM {
|
||||
} else if zone == RANDOM {
|
||||
zone = RANDOMS
|
||||
}
|
||||
fields := _zone_fields(m)
|
||||
@ -56,34 +52,24 @@ func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
|
||||
})
|
||||
}
|
||||
func _zone_export(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
f, p, e := miss.CreateFile(kit.Keys(file, CSV))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
m.Echo(p)
|
||||
defer m.Echo(p)
|
||||
w := csv.NewWriter(f)
|
||||
defer w.Flush()
|
||||
fields := _zone_fields(m)
|
||||
if kit.IndexOf(fields, EXTRA) == -1 {
|
||||
fields = append(fields, EXTRA)
|
||||
}
|
||||
w.Write(fields)
|
||||
defer Lock(m, prefix, chain)()
|
||||
keys := []string{}
|
||||
Richs(m, prefix, chain, FOREACH, func(key string, val ice.Map) { keys = append(keys, key) })
|
||||
kit.Sort(keys)
|
||||
head := kit.AddUniq(_zone_fields(m), EXTRA)
|
||||
w.Write(head)
|
||||
count := 0
|
||||
for _, key := range keys {
|
||||
for _, key := range kit.SortedKey(m.Confv(prefix, kit.Keys(chain, HASH))) {
|
||||
Richs(m, prefix, chain, key, func(key string, val ice.Map) {
|
||||
val = kit.GetMeta(val)
|
||||
chain := kit.Keys(chain, HASH, key)
|
||||
defer RLock(m, prefix, chain)()
|
||||
defer Lock(m, prefix, chain)()
|
||||
Grows(m, prefix, chain, "", "", func(value ice.Map) {
|
||||
value = kit.GetMeta(value)
|
||||
list := []string{}
|
||||
for _, k := range fields {
|
||||
list = append(list, kit.Select(kit.Format(kit.Value(val, k)), kit.Format(kit.Value(value, k))))
|
||||
}
|
||||
w.Write(list)
|
||||
w.Write(kit.Simple(head, func(k string) string { return kit.Select(kit.Format(kit.Value(val, k)), kit.Format(kit.Value(value, k))) }))
|
||||
count++
|
||||
})
|
||||
})
|
||||
@ -92,13 +78,13 @@ func _zone_export(m *ice.Message, prefix, chain, file string) {
|
||||
m.Conf(prefix, kit.Keys(chain, HASH), "")
|
||||
}
|
||||
func _zone_import(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
f, e := miss.OpenFile(kit.Keys(file, CSV))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
r := csv.NewReader(f)
|
||||
head, _ := r.Read()
|
||||
zkey := kit.Select(head[0], m.OptionFields())
|
||||
defer Lock(m, prefix, chain)()
|
||||
list := ice.Maps{}
|
||||
count := 0
|
||||
for {
|
||||
@ -106,8 +92,7 @@ func _zone_import(m *ice.Message, prefix, chain, file string) {
|
||||
if e != nil {
|
||||
break
|
||||
}
|
||||
zone := ""
|
||||
data := kit.Dict()
|
||||
zone, data := "", kit.Dict()
|
||||
for i, k := range head {
|
||||
switch k {
|
||||
case zkey:
|
||||
@ -156,49 +141,54 @@ func ZoneAction(arg ...ice.Any) ice.Actions {
|
||||
func PageZoneAction(arg ...ice.Any) ice.Actions {
|
||||
return ice.MergeActions(ice.Actions{
|
||||
SELECT: {Name: "select zone id auto insert page", Hand: func(m *ice.Message, arg ...string) { PageZoneSelect(m, arg...) }},
|
||||
NEXT: {Hand: func(m *ice.Message, arg ...string) { NextPageLimit(m, arg[0], arg[1:]...) }},
|
||||
PREV: {Hand: func(m *ice.Message, arg ...string) { PrevPage(m, arg[0], arg[1:]...) }},
|
||||
NEXT: {Hand: func(m *ice.Message, arg ...string) { NextPage(m, arg[0], arg[1:]...) }},
|
||||
PREV: {Hand: func(m *ice.Message, arg ...string) { PrevPageLimit(m, arg[0], arg[1:]...) }},
|
||||
}, ZoneAction(arg...))
|
||||
}
|
||||
func ZoneShort(m *ice.Message) string {
|
||||
return kit.Select(ZONE, m.Config(SHORT), m.Config(SHORT) != UNIQ)
|
||||
func ZoneKey(m *ice.Message) string {
|
||||
if m.Option(HASH) != "" {
|
||||
return HASH
|
||||
}
|
||||
return ZoneShort(m)
|
||||
}
|
||||
func ZoneShort(m *ice.Message) string { return kit.Select(ZONE, m.Config(SHORT), m.Config(SHORT) != UNIQ) }
|
||||
func ZoneField(m *ice.Message) string { return kit.Select(ZONE_FIELD, m.Config(FIELD)) }
|
||||
func ZoneInputs(m *ice.Message, arg ...Any) {
|
||||
m.Cmdy(INPUTS, m.PrefixKey(), "", ZONE, m.Option(ZoneShort(m)), arg)
|
||||
m.Cmdy(INPUTS, m.PrefixKey(), "", ZONE, m.Option(ZoneKey(m)), arg)
|
||||
}
|
||||
func ZoneCreate(m *ice.Message, arg ...Any) {
|
||||
m.Cmdy(INSERT, m.PrefixKey(), "", HASH, arg)
|
||||
}
|
||||
func ZoneRemove(m *ice.Message, arg ...Any) {
|
||||
if args := kit.Simple(arg...); len(args) == 0 {
|
||||
arg = append(arg, m.OptionSimple(ZoneShort(m), HASH))
|
||||
arg = append(arg, m.OptionSimple(ZoneKey(m)))
|
||||
} else if len(args) == 1 {
|
||||
arg = kit.List(ZoneShort(m), args[0])
|
||||
arg = kit.List(ZoneKey(m), args[0])
|
||||
}
|
||||
m.Cmdy(DELETE, m.PrefixKey(), "", HASH, arg)
|
||||
}
|
||||
func ZoneInsert(m *ice.Message, arg ...Any) {
|
||||
if args := kit.Simple(arg...); args[0] == ZoneShort(m) {
|
||||
if args := kit.Simple(arg...); args[0] == ZoneKey(m) {
|
||||
m.Cmdy(INSERT, m.PrefixKey(), "", ZONE, args[1:])
|
||||
} else {
|
||||
m.Cmdy(INSERT, m.PrefixKey(), "", ZONE, arg)
|
||||
}
|
||||
}
|
||||
func ZoneModify(m *ice.Message, arg ...Any) {
|
||||
m.Cmdy(MODIFY, m.PrefixKey(), "", ZONE, m.Option(ZoneShort(m)), m.Option(ID), arg)
|
||||
if args := kit.Simple(arg...); args[0] == HASH || args[0] == ZoneShort(m) {
|
||||
m.Cmdy(MODIFY, m.PrefixKey(), "", ZONE, args[1], args[3], arg[4:])
|
||||
} else {
|
||||
m.Cmdy(MODIFY, m.PrefixKey(), "", ZONE, m.Option(ZoneKey(m)), m.Option(ID), arg)
|
||||
}
|
||||
}
|
||||
func ZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
arg = kit.Slice(arg, 0, 2)
|
||||
m.Fields(len(arg), kit.Fields(TIME, m.Config(SHORT), COUNT), ZoneField(m))
|
||||
if m.Cmdy(SELECT, m.PrefixKey(), "", ZONE, arg, logs.FileLineMeta(logs.FileLine(-1))); len(arg) == 0 {
|
||||
if m.Config(SHORT) != "" {
|
||||
m.Sort(m.Config(SHORT))
|
||||
}
|
||||
m.PushAction(m.Config(ACTION), REMOVE)
|
||||
m.StatusTimeCount()
|
||||
m.Sort(ZoneShort(m)).StatusTimeCount().PushAction(m.Config(ACTION), REMOVE)
|
||||
} else if len(arg) == 1 {
|
||||
m.StatusTimeCountTotal(m.Conf("", kit.Keys(HASH, HashSelectField(m, arg[0], HASH), kit.Keym(COUNT))))
|
||||
m.SortIntR(ID)
|
||||
m.StatusTimeCountTotal(_mdb_getmeta(m, "", kit.Keys(HASH, HashSelectField(m, arg[0], HASH)), COUNT))
|
||||
}
|
||||
return m
|
||||
}
|
||||
@ -211,10 +201,6 @@ func ZoneExport(m *ice.Message, arg ...Any) {
|
||||
func ZoneImport(m *ice.Message, arg ...Any) {
|
||||
m.Cmdy(IMPORT, m.PrefixKey(), "", ZONE, arg)
|
||||
}
|
||||
func PageZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
OptionPages(m, kit.Slice(arg, 2)...)
|
||||
return ZoneSelect(m, arg...)
|
||||
}
|
||||
func ZoneSelects(m *ice.Message, arg ...string) *ice.Message {
|
||||
m.OptionFields(ZoneField(m))
|
||||
return ZoneSelect(m, arg...)
|
||||
@ -228,3 +214,7 @@ func ZoneSelectCB(m *ice.Message, zone string, cb Any) *ice.Message {
|
||||
m.Option(CACHE_LIMIT, "-1")
|
||||
return ZoneSelect(m, zone)
|
||||
}
|
||||
func PageZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
OptionPages(m, kit.Slice(arg, 2)...)
|
||||
return ZoneSelect(m, arg...)
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ func _spide_head(m *ice.Message, req *http.Request, head ice.Maps, value ice.Map
|
||||
}
|
||||
}
|
||||
func _spide_send(m *ice.Message, name string, req *http.Request, timeout string) (*http.Response, error) {
|
||||
client := mdb.HashTarget(m, name, func() ice.Any { return &http.Client{Timeout: kit.Duration(timeout)} }).(*http.Client)
|
||||
client := mdb.HashSelectTarget(m, name, func() ice.Any { return &http.Client{Timeout: kit.Duration(timeout)} }).(*http.Client)
|
||||
return client.Do(req)
|
||||
}
|
||||
func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) {
|
||||
|
@ -98,7 +98,7 @@ func (frame *Frame) Start(m *ice.Message, arg ...string) bool {
|
||||
mdb.HashCreate(m, mdb.NAME, WEB, arg, m.OptionSimple(tcp.PROTO, ice.DEV), cli.STATUS, tcp.START)
|
||||
m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, WEB, m.OptionSimple(mdb.NAME, tcp.HOST, tcp.PORT), func(l net.Listener) {
|
||||
defer mdb.HashModify(m, m.OptionSimple(mdb.NAME), cli.STATUS, tcp.STOP)
|
||||
mdb.HashTarget(m, m.Option(mdb.NAME), func() ice.Any { return l })
|
||||
mdb.HashSelectTarget(m, m.Option(mdb.NAME), func() ice.Any { return l })
|
||||
m.Warn(frame.Server.Serve(l)) // 启动服务
|
||||
})
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func _xterm_get(m *ice.Message, h string) _xterm {
|
||||
|
||||
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
|
||||
mdb.HashModify(m, "view", m.Option(ice.MSG_DAEMON))
|
||||
return mdb.HashTarget(m, h, func() ice.Any {
|
||||
return mdb.HashSelectTarget(m, h, func() ice.Any {
|
||||
ls := kit.Split(kit.Select(nfs.SH, t))
|
||||
cmd := exec.Command(cli.SystemFind(m, ls[0]), ls[1:]...)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user