1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-09-10 08:06:53 +08:00
parent 9a192b012f
commit 0f8a77af25
4 changed files with 6 additions and 42 deletions

View File

@ -22,10 +22,6 @@ type Log struct {
type Frame struct{ p chan *Log } type Frame struct{ p chan *Log }
func (f *Frame) Begin(m *ice.Message, arg ...string) { func (f *Frame) Begin(m *ice.Message, arg ...string) {
f.p = make(chan *Log, ice.MOD_BUFS)
ice.Info.Log = func(m *ice.Message, p, l, s string) {
f.p <- &Log{c: m.Option(ice.LOG_DEBUG) == ice.TRUE, p: p, l: l, s: s}
}
} }
func (f *Frame) Start(m *ice.Message, arg ...string) { func (f *Frame) Start(m *ice.Message, arg ...string) {
if !ice.HasVar() { if !ice.HasVar() {
@ -40,6 +36,10 @@ func (f *Frame) Start(m *ice.Message, arg ...string) {
v[FILE] = bufio.NewWriter(f) v[FILE] = bufio.NewWriter(f)
} }
}) })
f.p = make(chan *Log, ice.MOD_BUFS)
ice.Info.Log = func(m *ice.Message, p, l, s string) {
f.p <- &Log{c: m.Option(ice.LOG_DEBUG) == ice.TRUE, p: p, l: l, s: s}
}
for { for {
select { select {
case l, ok := <-f.p: case l, ok := <-f.p:
@ -61,7 +61,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) {
view := mdb.Confm(m, VIEW, m.Conf(SHOW, kit.Keys(l.l, VIEW))) view := mdb.Confm(m, VIEW, m.Conf(SHOW, kit.Keys(l.l, VIEW)))
kit.If(ice.Info.Colors || l.c, func() { bio.WriteString(kit.Format(view[PREFIX])) }) kit.If(ice.Info.Colors || l.c, func() { bio.WriteString(kit.Format(view[PREFIX])) })
defer kit.If(ice.Info.Colors || l.c, func() { bio.WriteString(kit.Format(view[SUFFIX])) }) defer kit.If(ice.Info.Colors || l.c, func() { bio.WriteString(kit.Format(view[SUFFIX])) })
fmt.Fprint(bio, l.l, lex.SP, l.s+kit.Format("what %v", len(f.p))) fmt.Fprint(bio, l.l, lex.SP, l.s)
}) })
} }
} }

View File

@ -1,7 +1,6 @@
package mdb package mdb
import ( import (
"time"
"sync" "sync"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
@ -21,41 +20,9 @@ func getLock(m *ice.Message, arg ...string) *task.Lock {
} }
func Lock(m *ice.Message, arg ...string) func() { func Lock(m *ice.Message, arg ...string) func() {
return getLock(m, arg...).Lock() return getLock(m, arg...).Lock()
key := kit.Select(m.PrefixKey(), kit.Keys(arg))
m.Info("what %v", key)
cb := getLock(m, arg...).Lock()
m.Info("what %v", key)
go func() {
time.Sleep(30*time.Second)
if cb == nil {
return
}
cb()
m.Warn("lock time out %v %v", key, m.FormatStack(1, 100))
}()
return func() {
cb()
cb = nil
}
} }
func RLock(m *ice.Message, arg ...string) func() { func RLock(m *ice.Message, arg ...string) func() {
return getLock(m, arg...).RLock() return getLock(m, arg...).RLock()
key := kit.Select(m.PrefixKey(), kit.Keys(arg))
m.Info("what %v", key)
cb := getLock(m, arg...).RLock()
m.Info("what %v", key)
go func() {
time.Sleep(30*time.Second)
if cb == nil {
return
}
cb()
m.Warn("lock time out %v %v", key, m.FormatStack(1, 100))
}()
return func() {
cb()
cb = nil
}
} }
func ConfigSimple(m *ice.Message, key ...string) (res []string) { func ConfigSimple(m *ice.Message, key ...string) (res []string) {

View File

@ -163,8 +163,6 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
}), SPACE, next) { }), SPACE, next) {
break break
} }
m.Info("what %v", msg.FormatStack(1, 100))
m.Info("what %v", msg.FormatChain())
if kit.HasPrefixList(msg.Detailv(), "toast") { if kit.HasPrefixList(msg.Detailv(), "toast") {
break break
} }

View File

@ -149,14 +149,13 @@ func init() {
} }
func spideToken(m *ice.Message, api string, token, expire string, arg ...string) { func spideToken(m *ice.Message, api string, token, expire string, arg ...string) {
msg := mdb.HashSelect(m.Spawn(), m.OptionDefault(ACCESS, mdb.Config(m, ACCESS))) msg := mdb.HashSelect(m.Spawn(), m.OptionDefault(ACCESS, mdb.Config(m, ACCESS)))
m.Info("what token %v %v", msg.Append(expire), msg.Append(token))
if msg.Append(token) == "" || m.Time() > msg.Append(expire) { if msg.Append(token) == "" || m.Time() > msg.Append(expire) {
kit.If(api != TICKET_GETTICKET, func() { arg = append(arg, msg.AppendSimple(APPID, SECRET)...) }) kit.If(api != TICKET_GETTICKET, func() { arg = append(arg, msg.AppendSimple(APPID, SECRET)...) })
res := m.Cmd(web.SPIDE, WX, kit.Select(http.MethodGet, http.MethodPost, api == STABLE_TOKEN), api, arg) res := m.Cmd(web.SPIDE, WX, kit.Select(http.MethodGet, http.MethodPost, api == STABLE_TOKEN), api, arg)
if m.Warn(!kit.IsIn(res.Append("errcode"), "0", ""), res.Append("errmsg")) { if m.Warn(!kit.IsIn(res.Append("errcode"), "0", ""), res.Append("errmsg")) {
return return
} }
m.Info("what res: %v", res.FormatMeta()) m.Info("res: %v", res.FormatMeta())
mdb.HashModify(m, m.OptionSimple(ACCESS), expire, m.Time(kit.Format("%vs", res.Append(oauth.EXPIRES_IN))), token, res.Append(kit.Select(oauth.ACCESS_TOKEN, TICKET, api == TICKET_GETTICKET))) mdb.HashModify(m, m.OptionSimple(ACCESS), expire, m.Time(kit.Format("%vs", res.Append(oauth.EXPIRES_IN))), token, res.Append(kit.Select(oauth.ACCESS_TOKEN, TICKET, api == TICKET_GETTICKET)))
msg = mdb.HashSelect(m.Spawn(), m.Option(ACCESS)) msg = mdb.HashSelect(m.Spawn(), m.Option(ACCESS))
} }