mirror of
https://github.com/openziti/zrok.git
synced 2025-08-17 03:11:17 +02:00
more limits.Agent elaboration (#271)
This commit is contained in:
@ -5,23 +5,56 @@ import (
|
||||
"github.com/openziti/zrok/controller/store"
|
||||
"github.com/openziti/zrok/controller/zrokEdgeSdk"
|
||||
"github.com/sirupsen/logrus"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
cfg *Config
|
||||
ifx *influxReader
|
||||
zCfg *zrokEdgeSdk.Config
|
||||
str *store.Store
|
||||
close chan struct{}
|
||||
join chan struct{}
|
||||
}
|
||||
|
||||
func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Config, str *store.Store) (*Agent, error) {
|
||||
return &Agent{}, nil
|
||||
return &Agent{
|
||||
cfg: cfg,
|
||||
ifx: newInfluxReader(ifxCfg),
|
||||
zCfg: zCfg,
|
||||
str: str,
|
||||
close: make(chan struct{}),
|
||||
join: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *Agent) Start() error {
|
||||
return nil
|
||||
func (a *Agent) Start() {
|
||||
go a.run()
|
||||
}
|
||||
|
||||
func (a *Agent) Stop() {
|
||||
close(a.close)
|
||||
<-a.join
|
||||
}
|
||||
|
||||
func (a *Agent) Handle(u *metrics.Usage) error {
|
||||
logrus.Infof("handling: %v", u)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Agent) run() {
|
||||
logrus.Info("started")
|
||||
defer logrus.Info("stopped")
|
||||
|
||||
mainLoop:
|
||||
for {
|
||||
select {
|
||||
case <-time.After(a.cfg.Cycle):
|
||||
logrus.Info("insepection cycle")
|
||||
|
||||
case <-a.close:
|
||||
close(a.join)
|
||||
break mainLoop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user