diff options
author | Valery Piashchynski <[email protected]> | 2021-05-05 16:39:22 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-05 16:39:22 +0300 |
commit | 4fa94bb7f73a705293c2afd40fc1151a3aaa04e2 (patch) | |
tree | 6ffd858cade87600bbd4432f70db22f50c598db0 /plugins/broadcast/interface.go | |
parent | 9ee78f937d5be67058882dd3590f89da35bca239 (diff) |
- Initial broadcast commit
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/broadcast/interface.go')
-rw-r--r-- | plugins/broadcast/interface.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/broadcast/interface.go b/plugins/broadcast/interface.go new file mode 100644 index 00000000..923c8105 --- /dev/null +++ b/plugins/broadcast/interface.go @@ -0,0 +1,36 @@ +package broadcast + +import "encoding/json" + +// Broker defines the ability to operate as message passing broker. +type Broker interface { + // Serve serves broker. + Serve() error + + // Stop closes the consumption and disconnects broker. + Stop() + + // Subscribe broker to one or multiple topics. + Subscribe(upstream chan *Message, topics ...string) error + + // SubscribePattern broker to pattern. + SubscribePattern(upstream chan *Message, pattern string) error + + // Unsubscribe broker from one or multiple topics. + Unsubscribe(upstream chan *Message, topics ...string) error + + // UnsubscribePattern broker from pattern. + UnsubscribePattern(upstream chan *Message, pattern string) error + + // Publish one or multiple Channel. + Publish(messages ...*Message) error +} + +// Message represent single message. +type Message struct { + // Topic message been pushed into. + Topic string `json:"topic"` + + // Payload to be broadcasted. Must be valid json when transferred over RPC. + Payload json.RawMessage `json:"payload"` +} |