Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 7dfb442

Browse files
committed
Copy FromTime function from timestamp package so we don't have to vendor
something from Prometheus. Signed-off-by: Callum Styan <[email protected]>
1 parent e679638 commit 7dfb442

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

wal/wal_watcher.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/go-kit/kit/log/level"
2929
"github.com/pkg/errors"
3030
"github.com/prometheus/client_golang/prometheus"
31-
"github.com/prometheus/prometheus/pkg/timestamp"
3231
"github.com/prometheus/tsdb/fileutil"
3332
"github.com/prometheus/tsdb/record"
3433
)
@@ -79,6 +78,13 @@ var (
7978
)
8079
)
8180

81+
// This function is copied from prometheus/prometheus/pkg/timestamp to avoid adding vendor to TSDB repo.
82+
83+
// FromTime returns a new millisecond timestamp from a time.
84+
func FromTime(t time.Time) int64 {
85+
return t.Unix()*1000 + int64(t.Nanosecond())/int64(time.Millisecond)
86+
}
87+
8288
func init() {
8389
prometheus.MustRegister(watcherRecordsRead)
8490
prometheus.MustRegister(watcherRecordDecodeFails)
@@ -169,7 +175,7 @@ func (w *WALWatcher) loop() {
169175

170176
// We may encourter failures processing the WAL; we should wait and retry.
171177
for !isClosed(w.quit) {
172-
w.startTime = timestamp.FromTime(time.Now())
178+
w.startTime = FromTime(time.Now())
173179
if err := w.run(); err != nil {
174180
level.Error(w.logger).Log("msg", "error tailing WAL", "err", err)
175181
}

0 commit comments

Comments
 (0)