mirror of
https://github.com/openziti/zrok.git
synced 2025-02-16 18:20:51 +01:00
share action skeletons (#276)
This commit is contained in:
parent
fdc5154873
commit
662693c2c9
@ -32,15 +32,23 @@ type Agent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Config, str *store.Store) (*Agent, error) {
|
func NewAgent(cfg *Config, ifxCfg *metrics.InfluxConfig, zCfg *zrokEdgeSdk.Config, str *store.Store) (*Agent, error) {
|
||||||
return &Agent{
|
edge, err := zrokEdgeSdk.Client(zCfg)
|
||||||
cfg: cfg,
|
if err != nil {
|
||||||
ifx: newInfluxReader(ifxCfg),
|
return nil, err
|
||||||
zCfg: zCfg,
|
}
|
||||||
str: str,
|
a := &Agent{
|
||||||
queue: make(chan *metrics.Usage, 1024),
|
cfg: cfg,
|
||||||
close: make(chan struct{}),
|
ifx: newInfluxReader(ifxCfg),
|
||||||
join: make(chan struct{}),
|
zCfg: zCfg,
|
||||||
}, nil
|
str: str,
|
||||||
|
queue: make(chan *metrics.Usage, 1024),
|
||||||
|
shrWarningEnforce: []ShareAction{newShareWarningAction(str, edge)},
|
||||||
|
shrLimitEnforce: []ShareAction{newShareLimitAction(str, edge)},
|
||||||
|
shrLimitRelax: []ShareAction{newShareRelaxAction(str, edge)},
|
||||||
|
close: make(chan struct{}),
|
||||||
|
join: make(chan struct{}),
|
||||||
|
}
|
||||||
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Agent) Start() {
|
func (a *Agent) Start() {
|
||||||
|
21
controller/limits/shareLimitAction.go
Normal file
21
controller/limits/shareLimitAction.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 shareLimitAction struct {
|
||||||
|
str *store.Store
|
||||||
|
edge *rest_management_api_client.ZitiEdgeManagement
|
||||||
|
}
|
||||||
|
|
||||||
|
func newShareLimitAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *shareLimitAction {
|
||||||
|
return &shareLimitAction{str, edge}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *shareLimitAction) HandleShare(s *store.Share, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||||
|
logrus.Infof("limiting '%v'", s.Token)
|
||||||
|
return nil
|
||||||
|
}
|
21
controller/limits/shareRelaxAction.go
Normal file
21
controller/limits/shareRelaxAction.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 shareRelaxAction struct {
|
||||||
|
str *store.Store
|
||||||
|
edge *rest_management_api_client.ZitiEdgeManagement
|
||||||
|
}
|
||||||
|
|
||||||
|
func newShareRelaxAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *shareRelaxAction {
|
||||||
|
return &shareRelaxAction{str, edge}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *shareRelaxAction) HandleShare(s *store.Share, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||||
|
logrus.Infof("relaxing '%v'", s.Token)
|
||||||
|
return nil
|
||||||
|
}
|
21
controller/limits/shareWarningAction.go
Normal file
21
controller/limits/shareWarningAction.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 shareWarningAction struct {
|
||||||
|
str *store.Store
|
||||||
|
edge *rest_management_api_client.ZitiEdgeManagement
|
||||||
|
}
|
||||||
|
|
||||||
|
func newShareWarningAction(str *store.Store, edge *rest_management_api_client.ZitiEdgeManagement) *shareWarningAction {
|
||||||
|
return &shareWarningAction{str, edge}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *shareWarningAction) HandleShare(s *store.Share, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||||
|
logrus.Infof("warning '%v'", s.Token)
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user