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

* initial commit * add protoc-gen-gofast * update generated files * fix linting * fix consumers error on message conversion * fix copying values on transformers * initial commit * initial commit * add protoc-gen-gofast * update generated files * fix linting * fix consumers error on message conversion * fix copying values on transformers * embedded for forward compatible. * remove gogo * embedded for forward compatible. * update protoc compiler * fix linting * remove hex comment Signed-off-by: rodneyosodo <socials@rodneyosodo.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
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
|
|
|
|
// Close gracefully closes message publisher's connection.
|
|
Close() 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
|
|
|
|
// Close gracefully closes message subscriber's connection.
|
|
Close() error
|
|
}
|
|
|
|
// PubSub represents aggregation interface for publisher and subscriber.
|
|
type PubSub interface {
|
|
Publisher
|
|
Subscriber
|
|
}
|