/
types.go
46 lines (36 loc) · 892 Bytes
/
types.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
package internal
import "time"
type Settings struct {
Host string `yaml:"host"`
Path string `yaml:"path"`
Jobs []MetricsJob `yaml:"jobs"`
}
type MetricsJob struct {
DB DBSettings `yaml:"db"`
Period time.Duration `yaml:"period"`
Metrics []Metric `yaml:"metrics"`
}
type MetricType = string
const (
MetricTypeGauge MetricType = "gauge"
MetricTypeHistogram MetricType = "histogram"
MetricTypeSummary MetricType = "summary"
)
type Metric struct {
Name string `yaml:"name"`
Query string `yaml:"query"`
Type MetricType `yaml:"type"`
Values []string `yaml:"values"`
Labels []string `yaml:"labels"`
}
type DBSettings struct {
Driver string `yaml:"driver"`
DSN string `yaml:"dsn"`
}
type MetricExecutor interface {
Run() error
}
type metricExecutorFunc func() error
func (m metricExecutorFunc) Run() error {
return m()
}