mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 16:13:47 +01:00
account action skeletons (#276)
This commit is contained in:
parent
4995ddab90
commit
916251673f
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
|
||||
}
|
@ -37,19 +37,22 @@ func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Confi
|
||||
return nil, err
|
||||
}
|
||||
a := &Agent{
|
||||
cfg: cfg,
|
||||
ifx: newInfluxReader(ifxCfg),
|
||||
zCfg: zCfg,
|
||||
str: str,
|
||||
queue: make(chan *metrics.Usage, 1024),
|
||||
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{}),
|
||||
cfg: cfg,
|
||||
ifx: newInfluxReader(ifxCfg),
|
||||
zCfg: zCfg,
|
||||
str: str,
|
||||
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)},
|
||||
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{}),
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user