mirror of
https://github.com/openziti/zrok.git
synced 2025-06-20 09:48:07 +02:00
wire 'frontends' through supporting code (#650)
This commit is contained in:
parent
a1b3b16cff
commit
f260449604
@ -10,6 +10,7 @@ type Config struct {
|
|||||||
Shares int
|
Shares int
|
||||||
ReservedShares int
|
ReservedShares int
|
||||||
UniqueNames int
|
UniqueNames int
|
||||||
|
Frontends int
|
||||||
Bandwidth *BandwidthPerPeriod
|
Bandwidth *BandwidthPerPeriod
|
||||||
Cycle time.Duration
|
Cycle time.Duration
|
||||||
Enforcing bool
|
Enforcing bool
|
||||||
@ -49,6 +50,7 @@ func DefaultConfig() *Config {
|
|||||||
Shares: store.Unlimited,
|
Shares: store.Unlimited,
|
||||||
ReservedShares: store.Unlimited,
|
ReservedShares: store.Unlimited,
|
||||||
UniqueNames: store.Unlimited,
|
UniqueNames: store.Unlimited,
|
||||||
|
Frontends: store.Unlimited,
|
||||||
Bandwidth: DefaultBandwidthPerPeriod(),
|
Bandwidth: DefaultBandwidthPerPeriod(),
|
||||||
Enforcing: false,
|
Enforcing: false,
|
||||||
Cycle: 15 * time.Minute,
|
Cycle: 15 * time.Minute,
|
||||||
|
@ -37,6 +37,10 @@ func (rcc *configResourceCountClass) GetUniqueNames() int {
|
|||||||
return rcc.cfg.UniqueNames
|
return rcc.cfg.UniqueNames
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rcc *configResourceCountClass) GetFrontends() int {
|
||||||
|
return rcc.cfg.Frontends
|
||||||
|
}
|
||||||
|
|
||||||
func (rcc *configResourceCountClass) String() string {
|
func (rcc *configResourceCountClass) String() string {
|
||||||
return fmt.Sprintf("Config<environments: %d, shares: %d, reservedShares: %d, uniqueNames: %d>", rcc.cfg.Environments, rcc.cfg.Shares, rcc.cfg.ReservedShares, rcc.cfg.UniqueNames)
|
return fmt.Sprintf("Config<environments: %d, shares: %d, reservedShares: %d, uniqueNames: %d>", rcc.cfg.Environments, rcc.cfg.Shares, rcc.cfg.ReservedShares, rcc.cfg.UniqueNames)
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ type ResourceCountClass interface {
|
|||||||
GetShares() int
|
GetShares() int
|
||||||
GetReservedShares() int
|
GetReservedShares() int
|
||||||
GetUniqueNames() int
|
GetUniqueNames() int
|
||||||
|
GetFrontends() int
|
||||||
}
|
}
|
||||||
|
|
||||||
type BandwidthClass interface {
|
type BandwidthClass interface {
|
||||||
@ -42,6 +43,7 @@ type LimitClass struct {
|
|||||||
Shares int
|
Shares int
|
||||||
ReservedShares int
|
ReservedShares int
|
||||||
UniqueNames int
|
UniqueNames int
|
||||||
|
Frontends int
|
||||||
PeriodMinutes int
|
PeriodMinutes int
|
||||||
RxBytes int64
|
RxBytes int64
|
||||||
TxBytes int64
|
TxBytes int64
|
||||||
@ -77,6 +79,10 @@ func (lc LimitClass) GetUniqueNames() int {
|
|||||||
return lc.UniqueNames
|
return lc.UniqueNames
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lc LimitClass) GetFrontends() int {
|
||||||
|
return lc.Frontends
|
||||||
|
}
|
||||||
|
|
||||||
func (lc LimitClass) GetBackendMode() sdk.BackendMode {
|
func (lc LimitClass) GetBackendMode() sdk.BackendMode {
|
||||||
if lc.BackendMode == nil {
|
if lc.BackendMode == nil {
|
||||||
return ""
|
return ""
|
||||||
@ -121,6 +127,9 @@ func (lc LimitClass) String() string {
|
|||||||
if lc.UniqueNames > Unlimited {
|
if lc.UniqueNames > Unlimited {
|
||||||
out += fmt.Sprintf(", uniqueNames: %d", lc.UniqueNames)
|
out += fmt.Sprintf(", uniqueNames: %d", lc.UniqueNames)
|
||||||
}
|
}
|
||||||
|
if lc.Frontends > Unlimited {
|
||||||
|
out += fmt.Sprintf(", frontends: %d", lc.Frontends)
|
||||||
|
}
|
||||||
if lc.RxBytes > Unlimited || lc.TxBytes > Unlimited || lc.TotalBytes > Unlimited {
|
if lc.RxBytes > Unlimited || lc.TxBytes > Unlimited || lc.TotalBytes > Unlimited {
|
||||||
out += fmt.Sprintf(", periodMinutes: %d", lc.PeriodMinutes)
|
out += fmt.Sprintf(", periodMinutes: %d", lc.PeriodMinutes)
|
||||||
}
|
}
|
||||||
@ -140,12 +149,12 @@ func (lc LimitClass) String() string {
|
|||||||
var _ BandwidthClass = (*LimitClass)(nil)
|
var _ BandwidthClass = (*LimitClass)(nil)
|
||||||
|
|
||||||
func (str *Store) CreateLimitClass(lc *LimitClass, trx *sqlx.Tx) (int, error) {
|
func (str *Store) CreateLimitClass(lc *LimitClass, trx *sqlx.Tx) (int, error) {
|
||||||
stmt, err := trx.Prepare("insert into limit_classes (backend_mode, environments, shares, reserved_shares, unique_names, period_minutes, rx_bytes, tx_bytes, total_bytes, limit_action) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) returning id")
|
stmt, err := trx.Prepare("insert into limit_classes (backend_mode, environments, shares, reserved_shares, unique_names, frontends, period_minutes, rx_bytes, tx_bytes, total_bytes, limit_action) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) returning id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.Wrap(err, "error preparing limit_classes insert statement")
|
return 0, errors.Wrap(err, "error preparing limit_classes insert statement")
|
||||||
}
|
}
|
||||||
var id int
|
var id int
|
||||||
if err := stmt.QueryRow(lc.BackendMode, lc.Environments, lc.Shares, lc.ReservedShares, lc.UniqueNames, lc.PeriodMinutes, lc.RxBytes, lc.TxBytes, lc.TotalBytes, lc.LimitAction).Scan(&id); err != nil {
|
if err := stmt.QueryRow(lc.BackendMode, lc.Environments, lc.Shares, lc.ReservedShares, lc.UniqueNames, lc.Frontends, lc.PeriodMinutes, lc.RxBytes, lc.TxBytes, lc.TotalBytes, lc.LimitAction).Scan(&id); err != nil {
|
||||||
return 0, errors.Wrap(err, "error executing limit_classes insert statement")
|
return 0, errors.Wrap(err, "error executing limit_classes insert statement")
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user