2020-06-09 09:57:31 -07:00
|
|
|
// Copyright 2017 The Prometheus Authors
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package storage
|
|
|
|
|
2023-09-14 09:57:31 -07:00
|
|
|
import (
|
|
|
|
"github.com/prometheus/prometheus/util/annotations"
|
|
|
|
)
|
|
|
|
|
2020-07-31 08:03:02 -07:00
|
|
|
// lazyGenericSeriesSet is a wrapped series set that is initialised on first call to Next().
|
|
|
|
type lazyGenericSeriesSet struct {
|
|
|
|
init func() (genericSeriesSet, bool)
|
2020-06-09 09:57:31 -07:00
|
|
|
|
|
|
|
set genericSeriesSet
|
|
|
|
}
|
|
|
|
|
2020-07-31 08:03:02 -07:00
|
|
|
func (c *lazyGenericSeriesSet) Next() bool {
|
2020-06-09 09:57:31 -07:00
|
|
|
if c.set != nil {
|
|
|
|
return c.set.Next()
|
|
|
|
}
|
|
|
|
var ok bool
|
2020-07-31 08:03:02 -07:00
|
|
|
c.set, ok = c.init()
|
2020-06-09 09:57:31 -07:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2020-07-31 08:03:02 -07:00
|
|
|
func (c *lazyGenericSeriesSet) Err() error {
|
2020-06-09 09:57:31 -07:00
|
|
|
if c.set != nil {
|
|
|
|
return c.set.Err()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-31 08:03:02 -07:00
|
|
|
func (c *lazyGenericSeriesSet) At() Labels {
|
2020-06-09 09:57:31 -07:00
|
|
|
if c.set != nil {
|
|
|
|
return c.set.At()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-14 09:57:31 -07:00
|
|
|
func (c *lazyGenericSeriesSet) Warnings() annotations.Annotations {
|
2020-06-09 09:57:31 -07:00
|
|
|
if c.set != nil {
|
|
|
|
return c.set.Warnings()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-14 09:57:31 -07:00
|
|
|
type warningsOnlySeriesSet annotations.Annotations
|
2020-06-09 09:57:31 -07:00
|
|
|
|
2023-09-14 09:57:31 -07:00
|
|
|
func (warningsOnlySeriesSet) Next() bool { return false }
|
|
|
|
func (warningsOnlySeriesSet) Err() error { return nil }
|
|
|
|
func (warningsOnlySeriesSet) At() Labels { return nil }
|
|
|
|
func (c warningsOnlySeriesSet) Warnings() annotations.Annotations { return annotations.Annotations(c) }
|
2020-06-09 09:57:31 -07:00
|
|
|
|
|
|
|
type errorOnlySeriesSet struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
2023-09-14 09:57:31 -07:00
|
|
|
func (errorOnlySeriesSet) Next() bool { return false }
|
|
|
|
func (errorOnlySeriesSet) At() Labels { return nil }
|
|
|
|
func (s errorOnlySeriesSet) Err() error { return s.err }
|
|
|
|
func (errorOnlySeriesSet) Warnings() annotations.Annotations { return nil }
|