mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-17 20:05:17 +00:00
Clean up linter warnings about unused code and atomic package
Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
This commit is contained in:
parent
cb00d9259b
commit
bedd3c4175
@ -354,10 +354,6 @@ func (s *Silences) nowUTC() time.Time {
|
||||
return s.clock.Now().UTC()
|
||||
}
|
||||
|
||||
func (s *Silences) ticker(d time.Duration) *clock.Ticker {
|
||||
return s.clock.Ticker(d)
|
||||
}
|
||||
|
||||
// Maintenance garbage collects the silence state at the given interval. If the snapshot
|
||||
// file is set, a snapshot is written to it afterwards.
|
||||
// Terminates on receiving from stopc.
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -30,6 +29,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
pb "github.com/prometheus/alertmanager/silence/silencepb"
|
||||
"github.com/prometheus/alertmanager/types"
|
||||
@ -211,9 +211,9 @@ func TestSilences_Maintenance_SupportsCustomCallback(t *testing.T) {
|
||||
s := &Silences{st: state{}, logger: log.NewNopLogger(), clock: clock, metrics: newMetrics(nil, nil)}
|
||||
stopc := make(chan struct{})
|
||||
|
||||
var calls int32 = 0
|
||||
calls := atomic.NewInt32(0)
|
||||
go s.Maintenance(100*time.Millisecond, f.Name(), stopc, func() (int64, error) {
|
||||
atomic.AddInt32(&calls, 1)
|
||||
calls.Add(1)
|
||||
return 0, nil
|
||||
})
|
||||
runtime.Gosched()
|
||||
@ -224,7 +224,7 @@ func TestSilences_Maintenance_SupportsCustomCallback(t *testing.T) {
|
||||
close(stopc)
|
||||
|
||||
require.Eventually(t, func() bool {
|
||||
return atomic.LoadInt32(&calls) == 2
|
||||
return calls.Load() == 2
|
||||
}, 1*time.Millisecond, 50*time.Microsecond)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user