mirror of
https://github.com/openziti/zrok.git
synced 2025-08-14 02:05:39 +02:00
add trx to action interfaces; implement limit and relax for share (#276)
This commit is contained in:
committed by
Kenneth Bingham
parent
bf48ddec76
commit
427ef7e3f9
@ -1,8 +1,10 @@
|
||||
package limits
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/openziti/edge/rest_management_api_client"
|
||||
"github.com/openziti/zrok/controller/store"
|
||||
"github.com/openziti/zrok/controller/zrokEdgeSdk"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -15,7 +17,18 @@ func newShareLimitAction(str *store.Store, edge *rest_management_api_client.Ziti
|
||||
return &shareLimitAction{str, edge}
|
||||
}
|
||||
|
||||
func (a *shareLimitAction) HandleShare(s *store.Share, rxBytes, txBytes int64, limit *BandwidthPerPeriod) error {
|
||||
func (a *shareLimitAction) HandleShare(s *store.Share, _, _ int64, _ *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
||||
logrus.Infof("limiting '%v'", s.Token)
|
||||
|
||||
env, err := a.str.GetEnvironment(s.EnvironmentId, trx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := zrokEdgeSdk.DeleteServicePolicyDial(env.ZId, s.Token, a.edge); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Infof("removed service dial policy for '%v'", s.Token)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user