You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
661 B
31 lines
661 B
package plugin
|
|
|
|
import "time"
|
|
|
|
const (
|
|
defaultSchedulerIdleSleep = 613 * time.Second
|
|
)
|
|
|
|
type SchedulerConfig struct {
|
|
IdleSleepSeconds int32 `json:"idle_sleep_seconds"`
|
|
}
|
|
|
|
func DefaultSchedulerConfig() SchedulerConfig {
|
|
return SchedulerConfig{
|
|
IdleSleepSeconds: int32(defaultSchedulerIdleSleep / time.Second),
|
|
}
|
|
}
|
|
|
|
func normalizeSchedulerConfig(cfg SchedulerConfig) SchedulerConfig {
|
|
if cfg.IdleSleepSeconds <= 0 {
|
|
return DefaultSchedulerConfig()
|
|
}
|
|
return cfg
|
|
}
|
|
|
|
func (c SchedulerConfig) IdleSleepDuration() time.Duration {
|
|
if c.IdleSleepSeconds <= 0 {
|
|
return defaultSchedulerIdleSleep
|
|
}
|
|
return time.Duration(c.IdleSleepSeconds) * time.Second
|
|
}
|