根据配置决定要不要saveCandle
This commit is contained in:
parent
0a38a98954
commit
c548e79e87
@ -164,20 +164,37 @@ func (core *Core) SaveCandle(instId string, period string, rsp *CandleData, dura
|
|||||||
Data: v,
|
Data: v,
|
||||||
From: "rest",
|
From: "rest",
|
||||||
}
|
}
|
||||||
|
candle.PushToWriteLogChan(core)
|
||||||
//保存rest得到的candle
|
//保存rest得到的candle
|
||||||
saveCandle := os.Getenv("TEXUS_SAVECANDLE")
|
saveCandle := os.Getenv("TEXUS_SAVECANDLE")
|
||||||
if saveCandle == "true" {
|
|
||||||
candle.SetToKey(core)
|
|
||||||
}
|
|
||||||
// 发布到allCandles|publish, 给外部订阅者用于setToKey
|
// 发布到allCandles|publish, 给外部订阅者用于setToKey
|
||||||
arys := []string{ALLCANDLES_PUBLISH}
|
arys := []string{ALLCANDLES_PUBLISH}
|
||||||
if withWs {
|
if withWs {
|
||||||
arys = append(arys, ALLCANDLES_INNER_PUBLISH)
|
arys = append(arys, ALLCANDLES_INNER_PUBLISH)
|
||||||
}
|
}
|
||||||
|
// 如果candle都不需要存到redis,那么AddToGeneralCandleChnl也没有意义
|
||||||
|
if saveCandle == "true" {
|
||||||
|
candle.SetToKey(core)
|
||||||
core.AddToGeneralCandleChnl(&candle, arys)
|
core.AddToGeneralCandleChnl(&candle, arys)
|
||||||
time.Sleep(dura / time.Duration(leng))
|
time.Sleep(dura / time.Duration(leng))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (candle *Candle) PushToWriteLogChan(cr *Core) error {
|
||||||
|
did := candle.InstId + candle.Period + candle.Data[0].(string)
|
||||||
|
candle.Id = HashString(did)
|
||||||
|
ncd, _ := candle.ToStruct(cr)
|
||||||
|
fmt.Println("ncd: ", ncd)
|
||||||
|
cd, _ := json.Marshal(ncd)
|
||||||
|
wg := WriteLog{
|
||||||
|
Content: cd,
|
||||||
|
Tag: "sardine.log.candle." + candle.Period,
|
||||||
|
Id: candle.Id,
|
||||||
|
}
|
||||||
|
cr.WriteLogChan <- &wg
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func Daoxu(arr []interface{}) {
|
func Daoxu(arr []interface{}) {
|
||||||
var temp interface{}
|
var temp interface{}
|
||||||
@ -272,17 +289,6 @@ func (mx *MaX) SetToKey() ([]interface{}, error) {
|
|||||||
|
|
||||||
// 保证同一个 period, keyName ,在一个周期里,SaveToSortSet只会被执行一次
|
// 保证同一个 period, keyName ,在一个周期里,SaveToSortSet只会被执行一次
|
||||||
func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration, tsi int64, cl *Candle) {
|
func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration, tsi int64, cl *Candle) {
|
||||||
did := cl.InstId + cl.Period + cl.Data[0].(string)
|
|
||||||
cl.Id = HashString(did)
|
|
||||||
ncd, _ := cl.ToStruct(core)
|
|
||||||
fmt.Println("ncd: ", ncd)
|
|
||||||
cd, _ := json.Marshal(ncd)
|
|
||||||
wg := WriteLog{
|
|
||||||
Content: cd,
|
|
||||||
Tag: "sardine.log.candle." + cl.Period,
|
|
||||||
Id: cl.Id,
|
|
||||||
}
|
|
||||||
core.WriteLogChan <- &wg
|
|
||||||
|
|
||||||
refName := keyName + "|refer"
|
refName := keyName + "|refer"
|
||||||
refRes, _ := core.RedisCli.GetSet(refName, 1).Result()
|
refRes, _ := core.RedisCli.GetSet(refName, 1).Result()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user