mirror of
https://github.com/openziti/zrok.git
synced 2025-08-09 08:05:04 +02:00
better support for scoped/unscoped bandwidth limit coexistence (#606)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package limits
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/openziti/zrok/controller/store"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
@ -32,6 +31,10 @@ func (bc *configBandwidthClass) IsGlobal() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (bc *configBandwidthClass) IsScoped() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (bc *configBandwidthClass) GetLimitClassId() int {
|
||||
return -1
|
||||
}
|
||||
@ -65,8 +68,16 @@ func (bc *configBandwidthClass) GetLimitAction() store.LimitAction {
|
||||
}
|
||||
|
||||
func (bc *configBandwidthClass) String() string {
|
||||
if out, err := json.Marshal(bc.bw); err == nil {
|
||||
return fmt.Sprintf("Config<period: %d, %s, action: %s>", bc.periodInMinutes, string(out), bc.limitAction)
|
||||
out := fmt.Sprintf("ConfigClass<periodMinutes: %d", bc.periodInMinutes)
|
||||
if bc.bw.Rx > store.Unlimited {
|
||||
out += fmt.Sprintf(", rxBytes: %d", bc.bw.Rx)
|
||||
}
|
||||
return "<<ERROR>>"
|
||||
if bc.bw.Tx > store.Unlimited {
|
||||
out += fmt.Sprintf(", txBytes: %d", bc.bw.Tx)
|
||||
}
|
||||
if bc.bw.Total > store.Unlimited {
|
||||
out += fmt.Sprintf(", totalBytes: %d", bc.bw.Total)
|
||||
}
|
||||
out += fmt.Sprintf(", limitAction: %s>", bc.limitAction)
|
||||
return out
|
||||
}
|
||||
|
Reference in New Issue
Block a user