mirror of
https://github.com/openziti/zrok.git
synced 2025-06-20 01:37:52 +02:00
environment action skeletons (#276)
This commit is contained in:
parent
662693c2c9
commit
2ab6730e23
@ -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{}),
|
||||||
}
|
}
|
||||||
|
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…
x
Reference in New Issue
Block a user