mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-28 13:48:49 +08:00

* Initial commit Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Update subscriber interface Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Add tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * check subscription map Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Check topic id after topic Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * reword description Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Setup empty queue Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change mqtt implementation Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Switch statements Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Simplify Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change mqtt subscriber Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Protect subscription map Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix subscription Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Set client id Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Format Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change delete method Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
36 lines
975 B
Go
36 lines
975 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package messaging
|
|
|
|
// Publisher specifies message publishing API.
|
|
type Publisher interface {
|
|
// Publishes message to the stream.
|
|
Publish(topic string, msg Message) error
|
|
}
|
|
|
|
// MessageHandler represents Message handler for Subscriber.
|
|
type MessageHandler interface {
|
|
// Handle handles messages passed by underlying implementation.
|
|
Handle(msg Message) error
|
|
|
|
// Cancel is used for cleanup during unsubscribing and it's optional.
|
|
Cancel() error
|
|
}
|
|
|
|
// Subscriber specifies message subscription API.
|
|
type Subscriber interface {
|
|
// Subscribe subscribes to the message stream and consumes messages.
|
|
Subscribe(id, topic string, handler MessageHandler) error
|
|
|
|
// Unsubscribe unsubscribes from the message stream and
|
|
// stops consuming messages.
|
|
Unsubscribe(id, topic string) error
|
|
}
|
|
|
|
// PubSub represents aggregation interface for publisher and subscriber.
|
|
type PubSub interface {
|
|
Publisher
|
|
Subscriber
|
|
}
|