diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-04-03 00:07:58 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-04-03 00:07:58 (GMT) |
commit | e7fd3ffaa415c1ae72b8b36b73050d343936d1d3 (patch) | |
tree | 2090e3ffe13a7479842650f50bda170980ce2033 /src | |
parent | 04a00559a15f3e94520c5ff26fc90f26b1a37707 (diff) |
send updates after update/reconcile
Diffstat (limited to 'src')
-rw-r--r-- | src/rhctl/switch_control.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index 523269f..09c68a3 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -61,19 +61,18 @@ func (ctrl *SwitchControl) updateOverallState(update interface{}) { switch update.(type) { case SwitchState: // s := update.(SwitchState) - rhdl.Printf("SwitchCTRL overall-state: got switch update") + rhdl.Printf("SwitchCTRL: got switch update updateting overall-state") // TODO: update ctrl.state - // TODO: publish new "state" case ServerState: s := update.(ServerState) - rhdl.Printf("SwitchCTRL overall-state: got server update from '%s'", s.Name) + rhdl.Printf("SwitchCTRL: got server update from '%s' updateting overall-state", s.Name) // TODO: update ctrl.state - // TODO: publish new "state" default: - rhl.Printf("SwitchCTRL overall-state: got unknown state-update of type %T", update) + rhl.Printf("SwitchCTRL: got unknown state-update of type %T", update) return } - rhdl.Printf("SwitchCTRL overall-state: %+v", ctrl.state) + rhdl.Printf("SwitchCTRL: overall-state is now: %+v", ctrl.state) + return } type CommandType uint8 @@ -140,7 +139,6 @@ func handleServer(in <-chan ServerState, out chan<- ServerState) { func (ctrl *SwitchControl) reconcile() { rhdl.Printf("SwitchCTRL: reconciling state...") // TODO: set mood dependent on overall-state - // if mood changes publish new "state" // TODO: send out commands to switch, server to get missing infos @@ -155,6 +153,7 @@ func (ctrl *SwitchControl) Run() { go handleServer(srv.StateChanges, serverStateChanges) } + ctrl.reconcile() for { select { case update := <-ctrl.sw.Updates: @@ -168,11 +167,13 @@ func (ctrl *SwitchControl) Run() { ctrl.Updates.Pub(state, "switch:state") ctrl.updateOverallState(state) ctrl.reconcile() + ctrl.Updates.Pub(ctrl.state, "state") case state := <-serverStateChanges: rhdl.Printf("got server state update: %+v", state) ctrl.Updates.Pub(state, "server:state") ctrl.updateOverallState(state) ctrl.reconcile() + ctrl.Updates.Pub(ctrl.state, "state") case cmd := <-ctrl.Commands: ctrl.handleCommand(cmd) } |