/
types.go
60 lines (50 loc) · 1.32 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
package config
import (
"database/sql/driver"
"github.com/orb-community/orb/pkg/types"
"time"
)
// SinkConfigParser to be compatible with new sinks config is coming from eventbus
type SinkConfig struct {
SinkID string `json:"sink_id"`
OwnerID string `json:"owner_id"`
Config types.Metadata `json:"config"`
State PrometheusState `json:"state,omitempty"`
Msg string `json:"msg,omitempty"`
LastRemoteWrite time.Time `json:"last_remote_write,omitempty"`
}
const (
Unknown PrometheusState = iota
Active
Error
Idle
Warning
)
type PrometheusState int
var promStateMap = [...]string{
"unknown",
"active",
"error",
"idle",
"warning",
}
var promStateRevMap = map[string]PrometheusState{
"unknown": Unknown,
"active": Active,
"error": Error,
"idle": Idle,
"warning": Warning,
}
func (p PrometheusState) String() string {
return promStateMap[p]
}
func (p *PrometheusState) SetFromString(value string) error {
*p = promStateRevMap[value]
return nil
}
func (p PrometheusState) Value() (driver.Value, error) {
return p.String(), nil
}