summaryrefslogtreecommitdiff
path: root/pkg/pubsub
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-22 15:20:08 +0300
committerValery Piashchynski <[email protected]>2021-06-22 15:20:08 +0300
commit5627146e45afbb8f6566862c60a42a0b0aad2d0a (patch)
tree731e4157c3c09dabab60bd2c78910facf23fce75 /pkg/pubsub
parent1a2a1f4735e40675abf6cd9767c99374359ec2bb (diff)
- Move common interfaces and structures to the 'common' folder
- Update tests Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/pubsub')
-rw-r--r--pkg/pubsub/interface.go54
-rw-r--r--pkg/pubsub/psmessage.go15
2 files changed, 0 insertions, 69 deletions
diff --git a/pkg/pubsub/interface.go b/pkg/pubsub/interface.go
deleted file mode 100644
index 06252d70..00000000
--- a/pkg/pubsub/interface.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package pubsub
-
-/*
-This interface is in BETA. It might be changed.
-*/
-
-// PubSub interface designed to implement on any storage type to provide pub-sub abilities
-// Publisher used to receive messages from the PHP app via RPC
-// Subscriber should be implemented to subscribe to a topics and provide a connections list per topic
-// Reader return next message from the channel
-type PubSub interface {
- Publisher
- Subscriber
- Reader
-}
-
-type SubReader interface {
- Subscriber
- Reader
-}
-
-// Subscriber defines the ability to operate as message passing broker.
-// BETA interface
-type Subscriber interface {
- // Subscribe broker to one or multiple topics.
- Subscribe(connectionID string, topics ...string) error
-
- // Unsubscribe from one or multiply topics
- Unsubscribe(connectionID string, topics ...string) error
-
- // Connections returns all connections associated with the particular topic
- Connections(topic string, ret map[string]struct{})
-}
-
-// Publisher publish one or more messages
-// BETA interface
-type Publisher interface {
- // Publish one or multiple Channel.
- Publish(message *Message) error
-
- // PublishAsync publish message and return immediately
- // If error occurred it will be printed into the logger
- PublishAsync(message *Message)
-}
-
-// Reader interface should return next message
-type Reader interface {
- Next() (*Message, error)
-}
-
-// Constructor is a special pub-sub interface made to return a constructed PubSub type
-type Constructor interface {
- PSConstruct(key string) (PubSub, error)
-}
diff --git a/pkg/pubsub/psmessage.go b/pkg/pubsub/psmessage.go
deleted file mode 100644
index e33d9284..00000000
--- a/pkg/pubsub/psmessage.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package pubsub
-
-import json "github.com/json-iterator/go"
-
-// Message represents a single message with payload bound to a particular topic
-type Message struct {
- // Topic (channel in terms of redis)
- Topic string `json:"topic"`
- // Payload (on some decode stages might be represented as base64 string)
- Payload []byte `json:"payload"`
-}
-
-func (m *Message) MarshalBinary() (data []byte, err error) {
- return json.Marshal(m)
-}