environment action skeletons (#276)

This commit is contained in:
Michael Quigley 2023-03-27 11:43:58 -04:00
parent 662693c2c9
commit 2ab6730e23
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 78 additions and 12 deletions

View File

@ -18,15 +18,15 @@ type Agent struct {
zCfg *zrokEdgeSdk.Config zCfg *zrokEdgeSdk.Config
str *store.Store str *store.Store
queue chan *metrics.Usage queue chan *metrics.Usage
acctWarningEnforce []AccountAction acctWarningActions []AccountAction
acctLimitEnforce []AccountAction acctLimitActions []AccountAction
acctLimitRelax []AccountAction acctRelaxActions []AccountAction
envWarningEnforce []EnvironmentAction envWarningActions []EnvironmentAction
envLimitEnforce []EnvironmentAction envLimitActions []EnvironmentAction
envLimitRelax []EnvironmentAction envRelaxActions []EnvironmentAction
shrWarningEnforce []ShareAction shrWarningActions []ShareAction
shrLimitEnforce []ShareAction shrLimitActions []ShareAction
shrLimitRelax []ShareAction shrRelaxActions []ShareAction
close chan struct{} close chan struct{}
join chan struct{} join chan struct{}
} }
@ -42,9 +42,12 @@ func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Confi
zCfg: zCfg, zCfg: zCfg,
str: str, str: str,
queue: make(chan *metrics.Usage, 1024), queue: make(chan *metrics.Usage, 1024),
shrWarningEnforce: []ShareAction{newShareWarningAction(str, edge)}, envWarningActions: []EnvironmentAction{newEnvironmentWarningAction(str, edge)},
shrLimitEnforce: []ShareAction{newShareLimitAction(str, edge)}, envLimitActions: []EnvironmentAction{newEnvironmentLimitAction(str, edge)},
shrLimitRelax: []ShareAction{newShareRelaxAction(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{}), close: make(chan struct{}),
join: 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
}