prometheus

Форк
0
71 строка · 2.0 Кб
1
// Copyright 2017 The Prometheus Authors
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13

14
package storage
15

16
import (
17
	"github.com/prometheus/prometheus/util/annotations"
18
)
19

20
// lazyGenericSeriesSet is a wrapped series set that is initialised on first call to Next().
21
type lazyGenericSeriesSet struct {
22
	init func() (genericSeriesSet, bool)
23

24
	set genericSeriesSet
25
}
26

27
func (c *lazyGenericSeriesSet) Next() bool {
28
	if c.set != nil {
29
		return c.set.Next()
30
	}
31
	var ok bool
32
	c.set, ok = c.init()
33
	return ok
34
}
35

36
func (c *lazyGenericSeriesSet) Err() error {
37
	if c.set != nil {
38
		return c.set.Err()
39
	}
40
	return nil
41
}
42

43
func (c *lazyGenericSeriesSet) At() Labels {
44
	if c.set != nil {
45
		return c.set.At()
46
	}
47
	return nil
48
}
49

50
func (c *lazyGenericSeriesSet) Warnings() annotations.Annotations {
51
	if c.set != nil {
52
		return c.set.Warnings()
53
	}
54
	return nil
55
}
56

57
type warningsOnlySeriesSet annotations.Annotations
58

59
func (warningsOnlySeriesSet) Next() bool                          { return false }
60
func (warningsOnlySeriesSet) Err() error                          { return nil }
61
func (warningsOnlySeriesSet) At() Labels                          { return nil }
62
func (c warningsOnlySeriesSet) Warnings() annotations.Annotations { return annotations.Annotations(c) }
63

64
type errorOnlySeriesSet struct {
65
	err error
66
}
67

68
func (errorOnlySeriesSet) Next() bool                        { return false }
69
func (errorOnlySeriesSet) At() Labels                        { return nil }
70
func (s errorOnlySeriesSet) Err() error                      { return s.err }
71
func (errorOnlySeriesSet) Warnings() annotations.Annotations { return nil }
72

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.