summaryrefslogtreecommitdiff
path: root/pkg/pubsub/interface.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/pubsub/interface.go')
-rw-r--r--pkg/pubsub/interface.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/pubsub/interface.go b/pkg/pubsub/interface.go
new file mode 100644
index 00000000..caf8783f
--- /dev/null
+++ b/pkg/pubsub/interface.go
@@ -0,0 +1,32 @@
+package pubsub
+
+// PubSub ...
+type PubSub interface {
+ Publisher
+ Subscriber
+ Reader
+}
+
+// Subscriber defines the ability to operate as message passing broker.
+type Subscriber interface {
+ // Subscribe broker to one or multiple topics.
+ Subscribe(topics ...string) error
+
+ // Unsubscribe from one or multiply topics
+ Unsubscribe(topics ...string) error
+}
+
+// Publisher publish one or more messages
+type Publisher interface {
+ // Publish one or multiple Channel.
+ Publish(messages []*Message) error
+
+ // PublishAsync publish message and return immediately
+ // If error occurred it will be printed into the logger
+ PublishAsync(messages []*Message)
+}
+
+// Reader interface should return next message
+type Reader interface {
+ Next() (*Message, error)
+}