mirror of https://github.com/prometheus/prometheus
cmd: Replace usage of sync/atomic with uber-go/atomic
Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>pull/7683/head
parent
71e88d841b
commit
e825a3fab3
|
@ -30,7 +30,6 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -67,6 +66,8 @@ import (
|
||||||
"github.com/prometheus/prometheus/tsdb"
|
"github.com/prometheus/prometheus/tsdb"
|
||||||
"github.com/prometheus/prometheus/util/strutil"
|
"github.com/prometheus/prometheus/util/strutil"
|
||||||
"github.com/prometheus/prometheus/web"
|
"github.com/prometheus/prometheus/web"
|
||||||
|
|
||||||
|
"go.uber.org/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -801,18 +802,18 @@ func openDBWithMetrics(dir string, logger log.Logger, reg prometheus.Registerer,
|
||||||
}
|
}
|
||||||
|
|
||||||
type safePromQLNoStepSubqueryInterval struct {
|
type safePromQLNoStepSubqueryInterval struct {
|
||||||
value int64
|
value atomic.Int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func durationToInt64Millis(d time.Duration) int64 {
|
func durationToInt64Millis(d time.Duration) int64 {
|
||||||
return int64(d / time.Millisecond)
|
return int64(d / time.Millisecond)
|
||||||
}
|
}
|
||||||
func (i *safePromQLNoStepSubqueryInterval) Set(ev model.Duration) {
|
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 {
|
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) {
|
func reloadConfig(filename string, logger log.Logger, noStepSuqueryInterval *safePromQLNoStepSubqueryInterval, rls ...func(*config.Config) error) (err error) {
|
||||||
|
|
Loading…
Reference in New Issue