forked from Super-long/influxdb-comparisons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
39 lines (32 loc) · 837 Bytes
/
status.go
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
37
38
39
package dashboard
import (
. "github.com/antondavidsen/influxdb-comparisons/bulk_data_gen/common"
"time"
)
var (
StatusByteString = []byte("status") // heap optimization
// Field keys for 'air condition indoor' points.
ServiceUpFieldKey = []byte("service_up")
)
type StatusMeasurement struct {
timestamp time.Time
serviceUp Distribution
}
func NewStatusMeasurement(start time.Time) *StatusMeasurement {
//state
serviceUp := TSD(0, 1, 0)
return &StatusMeasurement{
timestamp: start,
serviceUp: serviceUp,
}
}
func (m *StatusMeasurement) Tick(d time.Duration) {
m.timestamp = m.timestamp.Add(d)
m.serviceUp.Advance()
}
func (m *StatusMeasurement) ToPoint(p *Point) bool {
p.SetMeasurementName(StatusByteString)
p.SetTimestamp(&m.timestamp)
p.AppendField(ServiceUpFieldKey, int(m.serviceUp.Get()))
return true
}