MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / DecodeSumKey

Function DecodeSumKey

internal/metrics/stat.go:70–88  ·  view source on GitHub ↗
(sumKey string)

Source from the content-addressed store, hash-verified

68}
69
70func DecodeSumKey(sumKey string) (serverId int64, timeString string, version int32, err error) {
71 var b = []byte(sumKey)
72 var timeIndex = bytes.Index(b, []byte{'_'})
73 if timeIndex < 0 {
74 return
75 }
76
77 timeString = string(b[:timeIndex])
78 b = b[timeIndex+1:]
79
80 if len(b) < 12 {
81 err = errors.New("invalid sum key")
82 return
83 }
84
85 version = int32(binary.BigEndian.Uint32(b[:4]))
86 serverId = int64(binary.BigEndian.Uint64(b[4:12]))
87 return
88}
89
90func EncodeSumValue(count uint64, total uint64) []byte {
91 var result [16]byte

Callers 2

TestStat_EncodeSumKeyFunction · 0.92
loadServerIdMapMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestStat_EncodeSumKeyFunction · 0.74