尝试给上报到elasticsearch的文档加_id

This commit is contained in:
zhangkun 2024-12-04 12:19:56 +08:00
parent 04a441d08c
commit 438be2e6ac
4 changed files with 23 additions and 5 deletions

View File

@ -280,10 +280,6 @@ func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration,
refName := keyName + "|refer" refName := keyName + "|refer"
refRes, err := core.RedisCli.GetSet(refName, 1).Result() refRes, err := core.RedisCli.GetSet(refName, 1).Result()
core.RedisCli.Expire(refName, extt) core.RedisCli.Expire(refName, extt)
if len(refRes) != 0 {
fmt.Println("refName exist: ", refName)
return
}
did := cl.InstId + cl.Period + cl.Data[0].(string) did := cl.InstId + cl.Period + cl.Data[0].(string)
cl.Id = hashString(did) 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, Tag: "sardine.log.candle." + cl.Period,
// Id: hashString(did), // Id: hashString(did),
} }
err = wg.Process(core) go func() {
core.WriteLogChan <- &wg
}()
// err = wg.Process(core)
if err != nil { if err != nil {
fmt.Println("writeLog err:", err) fmt.Println("writeLog err:", err)
} }
if len(refRes) != 0 {
fmt.Println("refName exist: ", refName)
return
}
core.SaveToSortSet(period, keyName, extt, tsi) core.SaveToSortSet(period, keyName, extt, tsi)
} }

View File

@ -83,6 +83,16 @@ func (rst *RestQueue) Save(cr *Core) {
cr.SaveCandle(rst.InstId, rst.Bar, rsp, rst.Duration, rst.WithWs) 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() { func (cr *Core) ShowSysTime() {
rsp, _ := cr.RestInvoke("/api/v5/public/time", rest.GET) rsp, _ := cr.RestInvoke("/api/v5/public/time", rest.GET)
fmt.Println("serverSystem time:", rsp) fmt.Println("serverSystem time:", rsp)

View File

@ -242,6 +242,9 @@ func main() {
go func() { go func() {
LoopSaveCandle(&cr) LoopSaveCandle(&cr)
}() }()
go func() {
core.WriteLogProcess(&cr)
}()
// 永久阻塞 // 永久阻塞
select {} select {}
} }

BIN
tunas

Binary file not shown.