Remove All() interface method
It's being removed in a future release and wasn't being used here anyway.
This commit is contained in:
parent
ec3bb1e8bb
commit
3c8e9be489
|
@ -241,7 +241,10 @@ func (s *Silences) Close() error {
|
|||
// for all its silences. The data provider may have access to an
|
||||
// optimized view of the data to perform this evaluation.
|
||||
func (s *Silences) Mutes(lset model.LabelSet) bool {
|
||||
resp, err := s.All()
|
||||
s.mtx.RLock()
|
||||
defer s.mtx.RUnlock()
|
||||
|
||||
resp, err := s.Query(uint(len(s.sils)), 0, types.ByEndsAt)
|
||||
if err != nil {
|
||||
log.Errorf("retrieving silences failed: %s", err)
|
||||
// In doubt, do not silence anything.
|
||||
|
@ -259,11 +262,6 @@ func (s *Silences) Mutes(lset model.LabelSet) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// All returns all existing silences.
|
||||
func (s *Silences) All() (*types.SilencesQueryResponse, error) {
|
||||
return s.Query(uint(len(s.sils)), 0, types.ByCreatedAt)
|
||||
}
|
||||
|
||||
// Query returns at most limit silences starting at offset.
|
||||
func (s *Silences) Query(limit, offset uint, fn types.SilencesLessFunc) (*types.SilencesQueryResponse, error) {
|
||||
s.mtx.RLock()
|
||||
|
|
|
@ -207,77 +207,6 @@ func TestSilencesDelete(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSilencesAll(t *testing.T) {
|
||||
var (
|
||||
t0 = time.Now()
|
||||
t1 = t0.Add(10 * time.Minute)
|
||||
t2 = t0.Add(20 * time.Minute)
|
||||
t3 = t0.Add(30 * time.Minute)
|
||||
)
|
||||
|
||||
insert := []*types.Silence{
|
||||
types.NewSilence(&model.Silence{
|
||||
Matchers: []*model.Matcher{
|
||||
{Name: "key", Value: "val"},
|
||||
},
|
||||
StartsAt: t0,
|
||||
EndsAt: t2,
|
||||
CreatedAt: t1,
|
||||
CreatedBy: "user",
|
||||
Comment: "test comment",
|
||||
}),
|
||||
types.NewSilence(&model.Silence{
|
||||
Matchers: []*model.Matcher{
|
||||
{Name: "key", Value: "val"},
|
||||
{Name: "key2", Value: "val2.*", IsRegex: true},
|
||||
},
|
||||
StartsAt: t1,
|
||||
EndsAt: t2,
|
||||
CreatedAt: t1,
|
||||
CreatedBy: "user2",
|
||||
Comment: "test comment",
|
||||
}),
|
||||
types.NewSilence(&model.Silence{
|
||||
Matchers: []*model.Matcher{
|
||||
{Name: "key", Value: "val"},
|
||||
},
|
||||
StartsAt: t2,
|
||||
EndsAt: t3,
|
||||
CreatedAt: t3,
|
||||
CreatedBy: "user",
|
||||
Comment: "another test comment",
|
||||
}),
|
||||
}
|
||||
|
||||
dir, err := ioutil.TempDir("", "silences_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
silences, err := NewSilences(dir, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, sil := range insert {
|
||||
uid, err := silences.Set(sil)
|
||||
if err != nil {
|
||||
t.Fatalf("Insert failed: %s", err)
|
||||
}
|
||||
sil.ID = uid
|
||||
}
|
||||
|
||||
res, err := silences.All()
|
||||
if err != nil {
|
||||
t.Fatalf("Retrieval failed: %s", err)
|
||||
}
|
||||
|
||||
if silenceListEqual(res.Silences, insert) {
|
||||
t.Errorf("Unexpected result")
|
||||
t.Fatalf(pretty.Compare(res, insert))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSilencesMutes(t *testing.T) {
|
||||
var (
|
||||
t0 = time.Now()
|
||||
|
|
|
@ -94,8 +94,6 @@ type Silences interface {
|
|||
// optimized view of the data to perform this evaluation.
|
||||
types.Muter
|
||||
|
||||
// All returns all existing silences.
|
||||
All() (*types.SilencesQueryResponse, error)
|
||||
// Set a new silence.
|
||||
Set(*types.Silence) (uint64, error)
|
||||
// Del removes a silence.
|
||||
|
|
Loading…
Reference in New Issue