summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhctl')
-rw-r--r--src/rhctl/playout_server.go2
-rw-r--r--src/rhctl/switch_control.go31
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
}
}