diff options
Diffstat (limited to 'events/types.go')
-rw-r--r-- | events/types.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/events/types.go b/events/types.go new file mode 100644 index 00000000..65a76d15 --- /dev/null +++ b/events/types.go @@ -0,0 +1,46 @@ +package events + +type EventBus interface { + SubscribeAll(subID string, ch chan<- Event) error + SubscribeP(subID string, pattern string, ch chan<- Event) error + Unsubscribe(subID string) + UnsubscribeP(subID, pattern string) + Len() uint + Send(ev Event) +} + +type Event interface { + Plugin() string + Type() EventType + Message() string +} + +type RREvent struct { + // event typ + typ EventType + // plugin + plugin string + // message + message string +} + +// NewEvent initializes new event +func NewEvent(t EventType, plugin string, msg string) *RREvent { + return &RREvent{ + typ: t, + plugin: plugin, + message: msg, + } +} + +func (r *RREvent) Type() EventType { + return r.typ +} + +func (r *RREvent) Message() string { + return r.message +} + +func (r *RREvent) Plugin() string { + return r.plugin +} |