Skip to content

Commit

Permalink
Add LabelValues.Close method
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Knudsen <[email protected]>
  • Loading branch information
aknuds1 committed Oct 9, 2023
1 parent c03952d commit 377a89a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions storage/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,6 @@ type LabelValues interface {
// Warnings is a collection of warnings that have occurred during iteration.
// Warnings could be non-empty even if iteration has not failed with an error.
Warnings() annotations.Annotations
// Close the iterator.
Close() error
}
5 changes: 5 additions & 0 deletions storage/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ func (m *mergedLabelValues) Warnings() annotations.Annotations {
return m.warnings
}

func (m *mergedLabelValues) Close() error {
return nil
}

// errLabelValues is an empty label values iterator with an error.
type errLabelValues struct {
err error
Expand All @@ -320,6 +324,7 @@ func (e errLabelValues) Next() bool { return false }
func (e errLabelValues) At() string { return "" }
func (e errLabelValues) Err() error { return e.err }
func (e errLabelValues) Warnings() annotations.Annotations { return e.warnings }
func (e errLabelValues) Close() error { return nil }

// ErrLabelValues returns a LabelValues with err.
func ErrLabelValues(err error) LabelValues {
Expand Down
4 changes: 4 additions & 0 deletions storage/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,10 @@ func (l *labelValuesList) Warnings() annotations.Annotations {
return l.warnings
}

func (*labelValuesList) Close() error {
return nil
}

func (m *mockGenericQuerier) LabelNames(context.Context, ...*labels.Matcher) ([]string, annotations.Annotations, error) {
m.mtx.Lock()
m.labelNamesCalls++
Expand Down
4 changes: 4 additions & 0 deletions storage/secondary.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (s *secondaryLabelValues) Warnings() annotations.Annotations {
return ws
}

func (s *secondaryLabelValues) Close() error {
return nil
}

func (s *secondaryQuerier) LabelNames(ctx context.Context, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
names, w, err := s.genericQuerier.LabelNames(ctx, matchers...)
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions tsdb/index/labelvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func (l *labelValuesV2) Warnings() annotations.Annotations {
return nil
}

func (l *labelValuesV2) Close() error {
return nil
}

type labelValuesV1 struct {
it *reflect.MapIter
matchers []*labels.Matcher
Expand Down Expand Up @@ -145,6 +149,10 @@ func (*labelValuesV1) Warnings() annotations.Annotations {
return nil
}

func (*labelValuesV1) Close() error {
return nil
}

func (r *Reader) LabelValuesIntersectingPostings(name string, postings Postings) storage.LabelValues {
if r.version == FormatV1 {
/* TODO
Expand Down Expand Up @@ -258,6 +266,10 @@ func (it *intersectLabelValues) Warnings() annotations.Annotations {
return nil
}

func (it *intersectLabelValues) Close() error {
return nil
}

// ListLabelValues is an iterator over a slice of label values.
type ListLabelValues struct {
cur string
Expand Down Expand Up @@ -292,6 +304,10 @@ func (*ListLabelValues) Warnings() annotations.Annotations {
return nil
}

func (*ListLabelValues) Close() error {
return nil
}

func (p *MemPostings) LabelValuesIntersectingPostings(name string, postings Postings) storage.LabelValues {
p.mtx.RLock()
defer p.mtx.RUnlock()
Expand Down

0 comments on commit 377a89a

Please sign in to comment.