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
|
||||||
|
}
|
@ -37,19 +37,22 @@ func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Confi
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
a := &Agent{
|
a := &Agent{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
ifx: newInfluxReader(ifxCfg),
|
ifx: newInfluxReader(ifxCfg),
|
||||||
zCfg: zCfg,
|
zCfg: zCfg,
|
||||||
str: str,
|
str: str,
|
||||||
queue: make(chan *metrics.Usage, 1024),
|
queue: make(chan *metrics.Usage, 1024),
|
||||||
envWarningActions: []EnvironmentAction{newEnvironmentWarningAction(str, edge)},
|
acctWarningActions: []AccountAction{newAccountWarningAction(str, edge)},
|
||||||
envLimitActions: []EnvironmentAction{newEnvironmentLimitAction(str, edge)},
|
acctLimitActions: []AccountAction{newAccountLimitAction(str, edge)},
|
||||||
envRelaxActions: []EnvironmentAction{newEnvironmentRelaxAction(str, edge)},
|
acctRelaxActions: []AccountAction{newAccountRelaxAction(str, edge)},
|
||||||
shrWarningActions: []ShareAction{newShareWarningAction(str, edge)},
|
envWarningActions: []EnvironmentAction{newEnvironmentWarningAction(str, edge)},
|
||||||
shrLimitActions: []ShareAction{newShareLimitAction(str, edge)},
|
envLimitActions: []EnvironmentAction{newEnvironmentLimitAction(str, edge)},
|
||||||
shrRelaxActions: []ShareAction{newShareRelaxAction(str, edge)},
|
envRelaxActions: []EnvironmentAction{newEnvironmentRelaxAction(str, edge)},
|
||||||
close: make(chan struct{}),
|
shrWarningActions: []ShareAction{newShareWarningAction(str, edge)},
|
||||||
join: make(chan struct{}),
|
shrLimitActions: []ShareAction{newShareLimitAction(str, edge)},
|
||||||
|
shrRelaxActions: []ShareAction{newShareRelaxAction(str, edge)},
|
||||||
|
close: make(chan struct{}),
|
||||||
|
join: make(chan struct{}),
|
||||||
}
|
}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user