diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-03-27 20:14:59 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-03-27 20:14:59 (GMT) |
commit | 61f48b85e0c0301b1c5384c09c822bc5e2265a4f (patch) | |
tree | fba14c1d2a00340dfe9635bf50f6f257894b742d /src/rhctl | |
parent | 3b9dc5639b9b26bb5a8e4324de47f77a00e0e86a (diff) |
receiving of updates from switch as well from servers works now
Diffstat (limited to 'src/rhctl')
-rw-r--r-- | src/rhctl/playout_server.go | 2 | ||||
-rw-r--r-- | src/rhctl/switch_control.go | 31 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go index 1f38f42..9f8b9d1 100644 --- a/src/rhctl/playout_server.go +++ b/src/rhctl/playout_server.go @@ -45,6 +45,7 @@ func (s ServerHealth) String() string { } type ServerStatus struct { + Name string Health ServerHealth Channel string } @@ -145,6 +146,7 @@ func ServerInit(name string, conf *Config) (srv *PlayoutServer, err error) { if conf.Servers[name].HeartbeatThreshold > 0 { srv.hbthreshold = conf.Servers[name].HeartbeatThreshold } + srv.status.Name = srv.name srv.status.Health = ServerDead srv.status.Channel = "" srv.Updates = make(chan ServerStatus, 8) diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index de5bf6d..40dd788 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -21,20 +21,39 @@ package main -import ( - "time" -) - type SwitchControl struct { sw *AudioSwitch servers []*PlayoutServer } -func (sw *SwitchControl) Run() { +func handleServer(in <-chan ServerStatus, out chan<- ServerStatus) { + for { + update := <-in + out <- update + } +} + +func (ctrl *SwitchControl) Run() { rhdl.Printf("SwitchCTRL: handler running...") + serverUpdates := make(chan ServerStatus, 8) + for _, srv := range ctrl.servers { + go handleServer(srv.Updates, serverUpdates) + } + for { - time.Sleep(time.Second) + select { + case update := <-ctrl.sw.Updates: + rhdl.Printf("got update from switch: %+v", update) + for _, srv := range ctrl.servers { + srv.SwitchUpdates <- update + } + // TODO: send out to all clients who are interested in this + case status := <-serverUpdates: + rhdl.Printf("got server status update: %+v", status) + // TODO: recalculate overall status and send out commands to switch + } + // TODO: add handler for requests from control clients } } |