environment action skeletons (#276)

This commit is contained in:
Michael Quigley 2023-03-27 11:43:58 -04:00 committed by Kenneth Bingham
parent caeebb71e6
commit 4995ddab90
No known key found for this signature in database
GPG Key ID: 31709281860130B6
4 changed files with 78 additions and 12 deletions

View File

@ -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{}),
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}