mirror of
https://github.com/openziti/zrok.git
synced 2025-06-25 04:02:15 +02:00
account action skeletons (#276)
This commit is contained in:
parent
2ab6730e23
commit
067d9901d6
21
controller/limits/accountLimitAction.go
Normal file
21
controller/limits/accountLimitAction.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 accountLimitAction struct {
|
||||||
|
str *store.Store
|
||||||
|
edge *rest_management_api_client.ZitiEdgeManagement
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAccountLimitAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *accountLimitAction {
|
||||||
|
return &accountLimitAction{str, edge}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *accountLimitAction) HandleAccount(acct *store.Account, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||||
|
logrus.Infof("limiting '%v'", acct.Email)
|
||||||
|
return nil
|
||||||
|
}
|
21
controller/limits/accountRelaxAction.go
Normal file
21
controller/limits/accountRelaxAction.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 accountRelaxAction struct {
|
||||||
|
str *store.Store
|
||||||
|
edge *rest_management_api_client.ZitiEdgeManagement
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAccountRelaxAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *accountRelaxAction {
|
||||||
|
return &accountRelaxAction{str, edge}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *accountRelaxAction) HandleAccount(acct *store.Account, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||||
|
logrus.Infof("relaxing '%v'", acct.Email)
|
||||||
|
return nil
|
||||||
|
}
|
21
controller/limits/accounttWarningAction.go
Normal file
21
controller/limits/accounttWarningAction.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 accountWarningAction struct {
|
||||||
|
str *store.Store
|
||||||
|
edge *rest_management_api_client.ZitiEdgeManagement
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAccountWarningAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *accountWarningAction {
|
||||||
|
return &accountWarningAction{str, edge}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *accountWarningAction) HandleAccount(acct *store.Account, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||||
|
logrus.Infof("warning '%v'", acct.Email)
|
||||||
|
return nil
|
||||||
|
}
|
@ -42,6 +42,9 @@ 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),
|
||||||
|
acctWarningActions: []AccountAction{newAccountWarningAction(str, edge)},
|
||||||
|
acctLimitActions: []AccountAction{newAccountLimitAction(str, edge)},
|
||||||
|
acctRelaxActions: []AccountAction{newAccountRelaxAction(str, edge)},
|
||||||
envWarningActions: []EnvironmentAction{newEnvironmentWarningAction(str, edge)},
|
envWarningActions: []EnvironmentAction{newEnvironmentWarningAction(str, edge)},
|
||||||
envLimitActions: []EnvironmentAction{newEnvironmentLimitAction(str, edge)},
|
envLimitActions: []EnvironmentAction{newEnvironmentLimitAction(str, edge)},
|
||||||
envRelaxActions: []EnvironmentAction{newEnvironmentRelaxAction(str, edge)},
|
envRelaxActions: []EnvironmentAction{newEnvironmentRelaxAction(str, edge)},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user