blob: 806e81ce2d3a72769963cd58a08a56cc68e017bc (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package events
import (
"fmt"
)
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 {
Type() fmt.Stringer
Plugin() string
Message() string
}
type event struct {
// event typ
typ fmt.Stringer
// plugin
plugin string
// message
message string
}
// NewEvent initializes new event
func NewEvent(t fmt.Stringer, plugin string, message string) *event {
if t.String() == "" || plugin == "" {
return nil
}
return &event{
typ: t,
plugin: plugin,
message: message,
}
}
func (r *event) Type() fmt.Stringer {
return r.typ
}
func (r *event) Message() string {
return r.message
}
func (r *event) Plugin() string {
return r.plugin
}
|