RC-5
This commit is contained in:
@@ -15,6 +15,8 @@ import (
|
||||
type Runtime struct {
|
||||
GuessMinIntervalSec int `json:"guess_min_interval_sec"`
|
||||
ClientSubmitIntervalSec int `json:"client_submit_interval_sec"`
|
||||
GuessLotteryWindowSec int `json:"guess_lottery_window_sec"`
|
||||
GuessLotteryMaxAccepted int `json:"guess_lottery_max_accepted"`
|
||||
TaskRangeBits int `json:"task_range_bits"`
|
||||
ActiveTaskCount int `json:"active_task_count"`
|
||||
PresenceTTLSec int `json:"presence_ttl_sec"`
|
||||
@@ -57,6 +59,8 @@ func Defaults() Runtime {
|
||||
return Runtime{
|
||||
GuessMinIntervalSec: envInt("DEFAULT_GUESS_MIN_INTERVAL_SEC", 10),
|
||||
ClientSubmitIntervalSec: envInt("DEFAULT_CLIENT_SUBMIT_INTERVAL_SEC", 11),
|
||||
GuessLotteryWindowSec: envInt("DEFAULT_GUESS_LOTTERY_WINDOW_SEC", 60),
|
||||
GuessLotteryMaxAccepted: envInt("DEFAULT_GUESS_LOTTERY_MAX_ACCEPTED", 0),
|
||||
TaskRangeBits: envInt("DEFAULT_TASK_RANGE_BITS", 28),
|
||||
ActiveTaskCount: envInt("DEFAULT_ACTIVE_TASK_COUNT", 1),
|
||||
PresenceTTLSec: envInt("DEFAULT_PRESENCE_TTL_SEC", 35),
|
||||
@@ -199,6 +203,12 @@ func Validate(v Runtime) error {
|
||||
if v.ClientSubmitIntervalSec <= v.GuessMinIntervalSec || v.ClientSubmitIntervalSec > 7200 {
|
||||
return fmt.Errorf("client_submit_interval_sec must be > guess_min_interval_sec and <= 7200")
|
||||
}
|
||||
if v.GuessLotteryWindowSec < 1 || v.GuessLotteryWindowSec > 3600 {
|
||||
return fmt.Errorf("guess_lottery_window_sec must be 1..3600")
|
||||
}
|
||||
if v.GuessLotteryMaxAccepted < 0 || v.GuessLotteryMaxAccepted > 100000 {
|
||||
return fmt.Errorf("guess_lottery_max_accepted must be 0..100000 (0 disables lottery)")
|
||||
}
|
||||
if v.TaskRangeBits < 8 || v.TaskRangeBits > 128 {
|
||||
return fmt.Errorf("task_range_bits must be 8..128")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user