diff --git a/core/candle.go b/core/candle.go index e7fd969..c3418d4 100644 --- a/core/candle.go +++ b/core/candle.go @@ -280,10 +280,6 @@ func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration, refName := keyName + "|refer" refRes, err := core.RedisCli.GetSet(refName, 1).Result() core.RedisCli.Expire(refName, extt) - if len(refRes) != 0 { - fmt.Println("refName exist: ", refName) - return - } did := cl.InstId + cl.Period + cl.Data[0].(string) cl.Id = hashString(did) @@ -294,10 +290,19 @@ func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration, Tag: "sardine.log.candle." + cl.Period, // Id: hashString(did), } - err = wg.Process(core) + go func() { + core.WriteLogChan <- &wg + }() + // err = wg.Process(core) if err != nil { fmt.Println("writeLog err:", err) } + + if len(refRes) != 0 { + fmt.Println("refName exist: ", refName) + return + } + core.SaveToSortSet(period, keyName, extt, tsi) } diff --git a/core/core.go b/core/core.go index 1bf081d..ba9b100 100644 --- a/core/core.go +++ b/core/core.go @@ -83,6 +83,16 @@ func (rst *RestQueue) Save(cr *Core) { cr.SaveCandle(rst.InstId, rst.Bar, rsp, rst.Duration, rst.WithWs) } +func WriteLogProcess(cr *Core) { + for { + wg := <-cr.WriteLogChan + go func(wg *WriteLog) { + fmt.Println("start writelog") + wg.Process(cr) + }(wg) + } +} + func (cr *Core) ShowSysTime() { rsp, _ := cr.RestInvoke("/api/v5/public/time", rest.GET) fmt.Println("serverSystem time:", rsp) diff --git a/main.go b/main.go index 237bf33..498826c 100644 --- a/main.go +++ b/main.go @@ -242,6 +242,9 @@ func main() { go func() { LoopSaveCandle(&cr) }() + go func() { + core.WriteLogProcess(&cr) + }() // 永久阻塞 select {} } diff --git a/tunas b/tunas index cdf19e9..b6e86f7 100755 Binary files a/tunas and b/tunas differ