aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/core/metrics/mock/int_gauge.go
blob: 8955107da9edaa51bca5aee51b637440920cfe26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package mock

import (
	"github.com/ydb-platform/ydb/library/go/core/metrics"
	"go.uber.org/atomic"
)

var _ metrics.IntGauge = (*IntGauge)(nil)

// IntGauge tracks single int64 value.
type IntGauge struct {
	Name  string
	Tags  map[string]string
	Value *atomic.Int64
}

func (g *IntGauge) Set(value int64) {
	g.Value.Store(value)
}

func (g *IntGauge) Add(value int64) {
	g.Value.Add(value)
}

var _ metrics.FuncIntGauge = (*FuncIntGauge)(nil)

type FuncIntGauge struct {
	function func() int64
}

func (g FuncIntGauge) Function() func() int64 {
	return g.function
}