-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
81 lines (65 loc) · 1.89 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"context"
log "github.com/sirupsen/logrus"
"github.com/tendermint/tendermint/rpc/client/http"
"github.com/tendermint/tendermint/rpc/jsonrpc/client"
"sync"
"time"
)
type Config struct {
ctx context.Context
cancel context.CancelFunc
logger *log.Entry
PrometheusListenPort int `yaml:"prometheusListenPort"`
statsChan chan *promUpdate
queryInterval time.Duration
name string `yaml:"name"`
client *client.URIClient
rpcClient *http.HTTP // legit tendermint client
noNodes bool // tracks if all nodes are down
valInfo *ValInfo // recent validator state, only refreshed every few minutes
lastValInfo *ValInfo // use for detecting newly-jailed/tombstone
blocksResults []int
lastError string
lastBlockTime time.Time
lastBlockAlarm bool
lastBlockMtx *sync.Mutex
lastBlockNum int64
activeAlerts int
statTotalSigns float64
statTotalProps float64
statTotalMiss float64
statConsecutiveMiss float64
ChainId string `yaml:"chain_id"`
ValAddress string `yaml:"valoper_address"`
ExtraInfo string `yaml:"extra_info"`
Nodes []*NodeConfig `yaml:"nodes"`
Healthcheck HealthcheckConfig `yaml:"healthcheck"`
PublicFallback bool `yaml:"public_fallback"`
}
// NodeConfig holds the basic information for a node to connect to.
type NodeConfig struct {
Url string `yaml:"url"`
AlertIfDown bool `yaml:"alert_if_down"`
down bool
wasDown bool
syncing bool
lastMsg string
downSince time.Time
}
type HealthcheckConfig struct {
Enabled bool `yaml:"enabled"`
PingURL string `yaml:"ping_url"`
PingRate time.Duration `yaml:"ping_rate"`
}
func (c *Config) mkUpdate(t metricType, v float64, node string) *promUpdate {
return &promUpdate{
metric: t,
counter: v,
name: c.name,
chainId: c.ChainId,
moniker: c.valInfo.Moniker,
endpoint: node,
}
}