-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrolmessage.go
More file actions
35 lines (28 loc) · 910 Bytes
/
controlmessage.go
File metadata and controls
35 lines (28 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package dispatch
import "github.com/sirupsen/logrus"
// ControlAction represents the possible control actions dispatch understands
type ControlAction int
const (
// ControlAddListener adds a new EventListener
ControlAddListener ControlAction = iota
ControlShowListener
)
// ControlMessage describes a Dispatch control message
type ControlMessage struct {
Action ControlAction
ControlData interface{}
}
func processControl(msg ControlMessage) {
logrus.WithField("controlMessage", msg).
Debug("ControlMessage")
switch msg.Action {
case ControlAddListener:
d, _ := msg.ControlData.(EventListener)
route := toRouteString(d.Namespace, d.Action)
listener[route] = append(listener[route], d.EventChannel)
case ControlShowListener:
logrus.WithField("listener", listener).Info("Active Eventlistener")
default:
logrus.WithField("action", msg.Action).Error("Unkown Control Action")
}
}