account action skeletons (#276)

This commit is contained in:
Michael Quigley 2023-03-27 11:53:18 -04:00
parent 2ab6730e23
commit 067d9901d6
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 79 additions and 13 deletions

View 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
}

View 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
}

View 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
}

View File

@ -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)},