forked from grafana-cold-storage/metrictank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite.go
More file actions
36 lines (32 loc) · 959 Bytes
/
Copy pathwrite.go
File metadata and controls
36 lines (32 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package stats
import (
"strconv"
"time"
)
func WriteFloat64(buf, prefix, key []byte, val float64, now time.Time) []byte {
buf = append(buf, prefix...)
buf = append(buf, key...)
buf = append(buf, ' ')
buf = strconv.AppendFloat(buf, val, 'f', -1, 64)
buf = append(buf, ' ')
buf = strconv.AppendInt(buf, now.Unix(), 10)
return append(buf, '\n')
}
func WriteUint32(buf, prefix, key []byte, val uint32, now time.Time) []byte {
buf = append(buf, prefix...)
buf = append(buf, key...)
buf = append(buf, ' ')
buf = strconv.AppendUint(buf, uint64(val), 10)
buf = append(buf, ' ')
buf = strconv.AppendInt(buf, now.Unix(), 10)
return append(buf, '\n')
}
func WriteUint64(buf, prefix, key []byte, val uint64, now time.Time) []byte {
buf = append(buf, prefix...)
buf = append(buf, key...)
buf = append(buf, ' ')
buf = strconv.AppendUint(buf, val, 10)
buf = append(buf, ' ')
buf = strconv.AppendInt(buf, now.Unix(), 10)
return append(buf, '\n')
}