Files
EdgeNode/internal/metrics/stat.go

23 lines
578 B
Go
Raw Normal View History

2021-06-30 20:01:00 +08:00
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package metrics
import (
2021-08-22 10:07:04 +08:00
"encoding/json"
2021-06-30 20:01:00 +08:00
"github.com/cespare/xxhash"
"strconv"
)
type Stat struct {
ServerId int64
Keys []string
Hash string
Value int64
Time string
}
2021-08-22 10:07:04 +08:00
func SumStat(serverId int64, keys []string, time string, version int32, itemId int64) string {
keysData, _ := json.Marshal(keys)
return strconv.FormatUint(xxhash.Sum64String(strconv.FormatInt(serverId, 10)+"@"+string(keysData)+"@"+time+"@"+strconv.Itoa(int(version))+"@"+strconv.FormatInt(itemId, 10)), 10)
2021-06-30 20:01:00 +08:00
}