From e825a3fab347704b227041632197a2acde5c67c1 Mon Sep 17 00:00:00 2001 From: Javier Palomo Date: Tue, 28 Jul 2020 14:20:07 +0200 Subject: [PATCH] cmd: Replace usage of sync/atomic with uber-go/atomic Signed-off-by: Javier Palomo --- cmd/prometheus/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index e2fb6b26f..7f0375752 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -30,7 +30,6 @@ import ( "runtime" "strings" "sync" - "sync/atomic" "syscall" "time" @@ -67,6 +66,8 @@ import ( "github.com/prometheus/prometheus/tsdb" "github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/web" + + "go.uber.org/atomic" ) var ( @@ -801,18 +802,18 @@ func openDBWithMetrics(dir string, logger log.Logger, reg prometheus.Registerer, } type safePromQLNoStepSubqueryInterval struct { - value int64 + value atomic.Int64 } func durationToInt64Millis(d time.Duration) int64 { return int64(d / time.Millisecond) } func (i *safePromQLNoStepSubqueryInterval) Set(ev model.Duration) { - atomic.StoreInt64(&i.value, durationToInt64Millis(time.Duration(ev))) + i.value.Store(durationToInt64Millis(time.Duration(ev))) } func (i *safePromQLNoStepSubqueryInterval) Get(int64) int64 { - return atomic.LoadInt64(&i.value) + return i.value.Load() } func reloadConfig(filename string, logger log.Logger, noStepSuqueryInterval *safePromQLNoStepSubqueryInterval, rls ...func(*config.Config) error) (err error) {