zrok/controller/metrics.go

48 lines
743 B
Go
Raw Normal View History

2022-10-12 18:42:05 +02:00
package controller
2022-10-13 20:23:52 +02:00
import (
"github.com/sirupsen/logrus"
)
2022-10-12 18:42:05 +02:00
type MetricsConfig struct {
ServiceName string
Influx *InfluxConfig
2022-10-12 18:42:05 +02:00
}
type InfluxConfig struct {
Url string
Bucket string
Org string
Token string
}
2022-10-13 20:23:52 +02:00
type metricsAgent struct {
cfg *MetricsConfig
shutdown chan struct{}
joined chan struct{}
2022-10-13 20:23:52 +02:00
}
func newMetricsAgent(cfg *MetricsConfig) *metricsAgent {
return &metricsAgent{
cfg: cfg,
shutdown: make(chan struct{}),
joined: make(chan struct{}),
}
2022-10-13 20:23:52 +02:00
}
func (mtr *metricsAgent) run() {
logrus.Info("starting")
defer logrus.Info("exiting")
defer close(mtr.joined)
2022-10-13 20:23:52 +02:00
<-mtr.shutdown
}
func (mtr *metricsAgent) stop() {
close(mtr.shutdown)
}
func (mtr *metricsAgent) join() {
<-mtr.joined
2022-10-13 20:23:52 +02:00
}