diff --git a/core/candle.go b/core/candle.go index 9ce5419..0c41163 100644 --- a/core/candle.go +++ b/core/candle.go @@ -186,9 +186,6 @@ func hashString(input string) string { func (cl *Candle) ToStruct(core *Core) error { // cl.Timestamp - str := cl.InstId + "." + cl.Period + "." + cl.Data[0].(string) - cl.Id = hashString(str) - // 将字符串转换为 int64 类型的时间戳 ts, err := strconv.ParseInt(cl.Data[0].(string), 10, 64) if err != nil { @@ -287,11 +284,14 @@ func (core *Core) SaveUniKey(period string, keyName string, extt time.Duration, fmt.Println("refName exist: ", refName) return } + + did := cl.InstId + cl.Period + cl.Data[0].(string) cl.ToStruct(core) cd, _ := json.Marshal(cl) wg := WriteLog{ Content: cd, Tag: "sardine.log.candle." + cl.Period, + Id: hashString(did), } err = wg.Process(core) if err != nil { diff --git a/core/writeLog.go b/core/writeLog.go index 563ecc7..b5021f9 100644 --- a/core/writeLog.go +++ b/core/writeLog.go @@ -12,6 +12,7 @@ import ( type WriteLog struct { Content []byte Tag string + Id string } func (wg *WriteLog) Process(cr *Core) error { @@ -19,7 +20,7 @@ func (wg *WriteLog) Process(cr *Core) error { reqBody := bytes.NewBuffer(wg.Content) cr.Env = os.Getenv("GO_ENV") cr.FluentBitUrl = os.Getenv("TEXUS_FluentBitUrl") - fullUrl := "http://" + cr.FluentBitUrl + "/" + wg.Tag + fullUrl := "http://" + cr.FluentBitUrl + "/" + wg.Tag + "/_doc/" + wg.Id res, err := http.Post(fullUrl, "application/json", reqBody) fmt.Println("requested, response:", fullUrl, string(wg.Content), res) diff --git a/tunas b/tunas index 498f4f1..c84947e 100755 Binary files a/tunas and b/tunas differ