/usr/share/gocode/src/github.com/influxdata/influxdb/stress/v2/statement/timestamp.go is in golang-github-influxdb-influxdb-dev 1.1.1+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 40 41 42 43 44 45 46 47 48 49 50 51 | package statement
import (
"log"
"time"
)
// A Timestamp contains all informaiton needed to generate timestamps for points created by InsertStatements
type Timestamp struct {
Count int
Duration time.Duration
Jitter bool
}
// Time returns the next timestamp needed by the InsertStatement
func (t *Timestamp) Time(startDate string, series int, precision string) func() int64 {
var start time.Time
var err error
if startDate == "now" {
start = time.Now()
} else {
start, err = time.Parse("2006-01-02", startDate)
}
if err != nil {
log.Fatalf("Error parsing start time from StartDate\n string: %v\n error: %v\n", startDate, err)
}
return nextTime(start, t.Duration, series, precision)
}
func nextTime(ti time.Time, step time.Duration, series int, precision string) func() int64 {
t := ti
count := 0
return func() int64 {
count++
if count > series {
t = t.Add(step)
count = 1
}
var timestamp int64
if precision == "s" {
timestamp = t.Unix()
} else {
timestamp = t.UnixNano()
}
return timestamp
}
}
|