mirror of
https://github.com/openziti/zrok.git
synced 2024-11-29 11:34:07 +01:00
environment action skeletons (#276)
This commit is contained in:
parent
caeebb71e6
commit
4995ddab90
@ -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{}),
|
||||
}
|
||||
|
21
controller/limits/environmentLimitAction.go
Normal file
21
controller/limits/environmentLimitAction.go
Normal 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
|
||||
}
|
21
controller/limits/environmentRelaxAction.go
Normal file
21
controller/limits/environmentRelaxAction.go
Normal 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
|
||||
}
|
21
controller/limits/environmentWarningAction.go
Normal file
21
controller/limits/environmentWarningAction.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user