summaryrefslogtreecommitdiff
path: root/events/types.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-10-30 13:33:06 -0700
committerGitHub <[email protected]>2021-10-30 13:33:06 -0700
commitb78558d0af7f813f81de0338400f99291932347f (patch)
treee71fcd3ed2d8bbc1bb4542290a11d5cb9730a4b1 /events/types.go
parentc8c3f9f113eae13aa37cf92043b288bb0c68a622 (diff)
parent1cac0d3efd40e8950004c8d953fb5d1f2d53197b (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.go26
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
}