diff options
author | Valery Piashchynski <[email protected]> | 2021-10-30 13:33:06 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-10-30 13:33:06 -0700 |
commit | b78558d0af7f813f81de0338400f99291932347f (patch) | |
tree | e71fcd3ed2d8bbc1bb4542290a11d5cb9730a4b1 /events/types.go | |
parent | c8c3f9f113eae13aa37cf92043b288bb0c68a622 (diff) | |
parent | 1cac0d3efd40e8950004c8d953fb5d1f2d53197b (diff) |
[#839]: refactoring(eventsbus): add docs, udpate testsv2.6.0-alpha.2
[#839]: refactoring(eventsbus): add docs, udpate tests
Diffstat (limited to 'events/types.go')
-rw-r--r-- | events/types.go | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/events/types.go b/events/types.go index 65a76d15..806e81ce 100644 --- a/events/types.go +++ b/events/types.go @@ -1,5 +1,9 @@ package events +import ( + "fmt" +) + type EventBus interface { SubscribeAll(subID string, ch chan<- Event) error SubscribeP(subID string, pattern string, ch chan<- Event) error @@ -10,14 +14,14 @@ type EventBus interface { } type Event interface { + Type() fmt.Stringer Plugin() string - Type() EventType Message() string } -type RREvent struct { +type event struct { // event typ - typ EventType + typ fmt.Stringer // plugin plugin string // message @@ -25,22 +29,26 @@ type RREvent struct { } // NewEvent initializes new event -func NewEvent(t EventType, plugin string, msg string) *RREvent { - return &RREvent{ +func NewEvent(t fmt.Stringer, plugin string, message string) *event { + if t.String() == "" || plugin == "" { + return nil + } + + return &event{ typ: t, plugin: plugin, - message: msg, + message: message, } } -func (r *RREvent) Type() EventType { +func (r *event) Type() fmt.Stringer { return r.typ } -func (r *RREvent) Message() string { +func (r *event) Message() string { return r.message } -func (r *RREvent) Plugin() string { +func (r *event) Plugin() string { return r.plugin } |