diff --git a/controller/limits/agent.go b/controller/limits/agent.go index 0417ba47..f693c111 100644 --- a/controller/limits/agent.go +++ b/controller/limits/agent.go @@ -18,15 +18,15 @@ type Agent struct { zCfg *zrokEdgeSdk.Config str *store.Store queue chan *metrics.Usage - acctWarningEnforce []AccountAction - acctLimitEnforce []AccountAction - acctLimitRelax []AccountAction - envWarningEnforce []EnvironmentAction - envLimitEnforce []EnvironmentAction - envLimitRelax []EnvironmentAction - shrWarningEnforce []ShareAction - shrLimitEnforce []ShareAction - shrLimitRelax []ShareAction + acctWarningActions []AccountAction + acctLimitActions []AccountAction + acctRelaxActions []AccountAction + envWarningActions []EnvironmentAction + envLimitActions []EnvironmentAction + envRelaxActions []EnvironmentAction + shrWarningActions []ShareAction + shrLimitActions []ShareAction + shrRelaxActions []ShareAction close chan struct{} join chan struct{} } @@ -42,9 +42,12 @@ func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Confi zCfg: zCfg, str: str, queue: make(chan *metrics.Usage, 1024), - shrWarningEnforce: []ShareAction{newShareWarningAction(str, edge)}, - shrLimitEnforce: []ShareAction{newShareLimitAction(str, edge)}, - shrLimitRelax: []ShareAction{newShareRelaxAction(str, edge)}, + envWarningActions: []EnvironmentAction{newEnvironmentWarningAction(str, edge)}, + envLimitActions: []EnvironmentAction{newEnvironmentLimitAction(str, edge)}, + envRelaxActions: []EnvironmentAction{newEnvironmentRelaxAction(str, edge)}, + shrWarningActions: []ShareAction{newShareWarningAction(str, edge)}, + shrLimitActions: []ShareAction{newShareLimitAction(str, edge)}, + shrRelaxActions: []ShareAction{newShareRelaxAction(str, edge)}, close: make(chan struct{}), join: make(chan struct{}), } diff --git a/controller/limits/environmentLimitAction.go b/controller/limits/environmentLimitAction.go new file mode 100644 index 00000000..c7d32b72 --- /dev/null +++ b/controller/limits/environmentLimitAction.go @@ -0,0 +1,21 @@ +package limits + +import ( + "github.com/openziti/edge/rest_management_api_client" + "github.com/openziti/zrok/controller/store" + "github.com/sirupsen/logrus" +) + +type environmentLimitAction struct { + str *store.Store + edge *rest_management_api_client.ZitiEdgeManagement +} + +func newEnvironmentLimitAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *environmentLimitAction { + return &environmentLimitAction{str, edge} +} + +func (a *environmentLimitAction) HandleEnvironment(e *store.Environment, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error { + logrus.Infof("limiting '%v'", e.ZId) + return nil +} diff --git a/controller/limits/environmentRelaxAction.go b/controller/limits/environmentRelaxAction.go new file mode 100644 index 00000000..de4a833c --- /dev/null +++ b/controller/limits/environmentRelaxAction.go @@ -0,0 +1,21 @@ +package limits + +import ( + "github.com/openziti/edge/rest_management_api_client" + "github.com/openziti/zrok/controller/store" + "github.com/sirupsen/logrus" +) + +type environmentRelaxAction struct { + str *store.Store + edge *rest_management_api_client.ZitiEdgeManagement +} + +func newEnvironmentRelaxAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *environmentRelaxAction { + return &environmentRelaxAction{str, edge} +} + +func (a *environmentRelaxAction) HandleEnvironment(e *store.Environment, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error { + logrus.Infof("relaxing '%v'", e.ZId) + return nil +} diff --git a/controller/limits/environmentWarningAction.go b/controller/limits/environmentWarningAction.go new file mode 100644 index 00000000..b6298aa5 --- /dev/null +++ b/controller/limits/environmentWarningAction.go @@ -0,0 +1,21 @@ +package limits + +import ( + "github.com/openziti/edge/rest_management_api_client" + "github.com/openziti/zrok/controller/store" + "github.com/sirupsen/logrus" +) + +type environmentWarningAction struct { + str *store.Store + edge *rest_management_api_client.ZitiEdgeManagement +} + +func newEnvironmentWarningAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *environmentWarningAction { + return &environmentWarningAction{str, edge} +} + +func (a *environmentWarningAction) HandleEnvironment(e *store.Environment, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error { + logrus.Infof("warning '%v'", e.ZId) + return nil +}