mirror of
https://github.com/openziti/zrok.git
synced 2025-08-10 00:17:46 +02:00
wire in the new 'limits.Agent' infrastructure; extend the 'metrics.Agent' to support additional 'metrics.UsageSink' instances (#271)
This commit is contained in:
@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"context"
|
||||
"github.com/openziti/zrok/controller/config"
|
||||
"github.com/openziti/zrok/controller/limits"
|
||||
"github.com/openziti/zrok/controller/metrics"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@ -80,6 +81,18 @@ func Run(inCfg *config.Config) error {
|
||||
return errors.Wrap(err, "error starting metrics agent")
|
||||
}
|
||||
defer func() { ma.Stop() }()
|
||||
|
||||
if cfg.Limits != nil && cfg.Limits.Enforcing {
|
||||
la, err := limits.NewAgent(cfg.Limits, cfg.Metrics.Influx, cfg.Ziti, str)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating limits agent")
|
||||
}
|
||||
ma.AddUsageSink(la)
|
||||
if err := la.Start(); err != nil {
|
||||
return errors.Wrap(err, "error starting limits agent")
|
||||
}
|
||||
defer func() { la.Stop() }()
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
Reference in New Issue
Block a user