summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rhctl/conf.go16
-rw-r--r--src/rhctl/switch_control.go35
2 files changed, 43 insertions, 8 deletions
diff --git a/src/rhctl/conf.go b/src/rhctl/conf.go
index 8df11f0..3e35abb 100644
--- a/src/rhctl/conf.go
+++ b/src/rhctl/conf.go
@@ -73,6 +73,19 @@ type Config struct {
HeartbeatThreshold uint `toml:"heartbeat_threshold"`
}
+ Timing struct {
+ Settling struct {
+ Awakening Duration `toml:"awakening"`
+ SelectServer Duration `toml:"select_server"`
+ UpdateStates Duration `toml:"update_states"`
+ }
+
+ StaleStates struct {
+ CheckInterval Duration `toml:"check_interval"`
+ MaxAge Duration `toml:"max_age"`
+ }
+ }
+
Clients struct {
Web struct {
Address string `toml:"addr"`
@@ -90,6 +103,9 @@ type Duration struct {
func (d *Duration) UnmarshalTOML(data []byte) (err error) {
ds := strings.Trim(string(data), "\"")
d.Duration, err = time.ParseDuration(ds)
+ if err == nil && d.Duration < 0 {
+ err = errors.New("negative durations are not allowed")
+ }
return
}
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go
index 1cfd4f8..71f2d69 100644
--- a/src/rhctl/switch_control.go
+++ b/src/rhctl/switch_control.go
@@ -93,11 +93,11 @@ type SwitchControl struct {
settling *time.Timer
Updates *pubsub.PubSub
Commands chan *Command
- AwakeningSettlingTime time.Duration // 30 * time.Second
- SelectServerSettlingTime time.Duration // 10 * time.Second
- UpdateStatesSettlingTime time.Duration // 3 * time.Second
- StaleStateCheckInterval time.Duration // 1 * time.Minute
- StatesMaxAge time.Duration // 2 * time.Hour
+ AwakeningSettlingTime time.Duration
+ SelectServerSettlingTime time.Duration
+ UpdateStatesSettlingTime time.Duration
+ StaleStatesCheckInterval time.Duration
+ StatesMaxAge time.Duration
}
func (ctrl *SwitchControl) handleCommand(cmd *Command) {
@@ -331,7 +331,7 @@ func (ctrl *SwitchControl) Run() {
// send out commands to switch and/or server to get missing infos
ctrl.checkMissingOrStaleStates(0)
- staleTicker := time.NewTicker(ctrl.StaleStateCheckInterval)
+ staleTicker := time.NewTicker(ctrl.StaleStatesCheckInterval)
ctrl.reconcile("")
for {
@@ -380,11 +380,30 @@ func SwitchControlInit(conf *Config, sw *AudioSwitch, servers []*PlayoutServer)
ctrl.Updates = pubsub.NewNonBlocking(32)
ctrl.Commands = make(chan *Command, 8)
- // TODO: get this from conf
ctrl.AwakeningSettlingTime = 30 * time.Second
+ if conf.Timing.Settling.Awakening.Duration > time.Duration(0) {
+ ctrl.AwakeningSettlingTime = conf.Timing.Settling.Awakening.Duration
+ }
+
ctrl.SelectServerSettlingTime = 10 * time.Second
+ if conf.Timing.Settling.SelectServer.Duration > time.Duration(0) {
+ ctrl.SelectServerSettlingTime = conf.Timing.Settling.SelectServer.Duration
+ }
+
ctrl.UpdateStatesSettlingTime = 3 * time.Second
- ctrl.StaleStateCheckInterval = 1 * time.Minute
+ if conf.Timing.Settling.UpdateStates.Duration > time.Duration(0) {
+ ctrl.UpdateStatesSettlingTime = conf.Timing.Settling.UpdateStates.Duration
+ }
+
+ ctrl.StaleStatesCheckInterval = 1 * time.Minute
+ if conf.Timing.StaleStates.CheckInterval.Duration > time.Duration(0) {
+ ctrl.StaleStatesCheckInterval = conf.Timing.StaleStates.CheckInterval.Duration
+ }
+
ctrl.StatesMaxAge = 2 * time.Hour
+ if conf.Timing.StaleStates.MaxAge.Duration > time.Duration(0) {
+ ctrl.StatesMaxAge = conf.Timing.StaleStates.MaxAge.Duration
+ }
+
return
}