2023-03-10 20:25:29 +01:00
|
|
|
package limits
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
const Unlimited = -1
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Environments int
|
|
|
|
Shares int
|
|
|
|
Bandwidth *BandwidthConfig
|
2023-03-17 18:13:33 +01:00
|
|
|
Cycle time.Duration
|
2023-03-16 20:05:39 +01:00
|
|
|
Enforcing bool
|
2023-03-10 20:25:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type BandwidthConfig struct {
|
|
|
|
PerAccount *BandwidthPerPeriod
|
|
|
|
PerEnvironment *BandwidthPerPeriod
|
|
|
|
PerShare *BandwidthPerPeriod
|
|
|
|
}
|
|
|
|
|
|
|
|
type BandwidthPerPeriod struct {
|
2023-03-10 20:32:00 +01:00
|
|
|
Period time.Duration
|
|
|
|
Warning *Bandwidth
|
|
|
|
Limit *Bandwidth
|
|
|
|
}
|
|
|
|
|
|
|
|
type Bandwidth struct {
|
|
|
|
Rx int64
|
|
|
|
Tx int64
|
|
|
|
Total int64
|
2023-03-10 20:25:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultConfig() *Config {
|
|
|
|
return &Config{
|
|
|
|
Environments: Unlimited,
|
|
|
|
Shares: Unlimited,
|
|
|
|
Bandwidth: &BandwidthConfig{
|
|
|
|
PerAccount: &BandwidthPerPeriod{
|
|
|
|
Period: 365 * (24 * time.Hour),
|
2023-03-10 20:32:00 +01:00
|
|
|
Warning: &Bandwidth{
|
|
|
|
Rx: Unlimited,
|
|
|
|
Tx: Unlimited,
|
|
|
|
Total: Unlimited,
|
|
|
|
},
|
|
|
|
Limit: &Bandwidth{
|
|
|
|
Rx: Unlimited,
|
|
|
|
Tx: Unlimited,
|
|
|
|
Total: Unlimited,
|
|
|
|
},
|
2023-03-10 20:25:29 +01:00
|
|
|
},
|
|
|
|
PerEnvironment: &BandwidthPerPeriod{
|
|
|
|
Period: 365 * (24 * time.Hour),
|
2023-03-10 20:32:00 +01:00
|
|
|
Warning: &Bandwidth{
|
|
|
|
Rx: Unlimited,
|
|
|
|
Tx: Unlimited,
|
|
|
|
Total: Unlimited,
|
|
|
|
},
|
|
|
|
Limit: &Bandwidth{
|
|
|
|
Rx: Unlimited,
|
|
|
|
Tx: Unlimited,
|
|
|
|
Total: Unlimited,
|
|
|
|
},
|
2023-03-10 20:25:29 +01:00
|
|
|
},
|
|
|
|
PerShare: &BandwidthPerPeriod{
|
|
|
|
Period: 365 * (24 * time.Hour),
|
2023-03-10 20:32:00 +01:00
|
|
|
Warning: &Bandwidth{
|
|
|
|
Rx: Unlimited,
|
|
|
|
Tx: Unlimited,
|
|
|
|
Total: Unlimited,
|
|
|
|
},
|
|
|
|
Limit: &Bandwidth{
|
|
|
|
Rx: Unlimited,
|
|
|
|
Tx: Unlimited,
|
|
|
|
Total: Unlimited,
|
|
|
|
},
|
2023-03-10 20:25:29 +01:00
|
|
|
},
|
|
|
|
},
|
2023-03-17 18:13:33 +01:00
|
|
|
Enforcing: false,
|
|
|
|
Cycle: 15 * time.Minute,
|
2023-03-10 20:25:29 +01:00
|
|
|
}
|
|
|
|
}
|