Documentation
¶
Index ¶
- Constants
- Variables
- func FormatMessage(pc domain.PubConfigInfo, msg *protomfx.Message) error
- func NormalizeSubtopic(topic string) (string, error)
- func PayloadHash(payload []byte) int32
- func SplitMessage(message protomfx.Message) ([]protomfx.Message, error)
- func ToJSONCommand(cmd protomfx.Command) mfjson.Command
- func ToJSONMessage(message protomfx.Message) mfjson.Message
- func ToSenMLMessage(message protomfx.Message) (senml.Message, error)
- type AlarmHandler
- type AlarmPublisher
- type AlarmSubscriber
- type CommandHandler
- type CommandPublisher
- type CommandSubscriber
- type MessageDispatcher
- type MessageHandler
- type NotificationHandler
- type NotificationPublisher
- type NotificationSubscriber
- type PubSub
- type Publisher
- type Subscriber
- type WebhookHandler
- type WebhookPublisher
- type WebhookSubscriber
Constants ¶
const ( SenMLContentType = "application/senml+json" JSONContentType = "application/json" )
Variables ¶
var ( // ErrPublishMessage indicates that message publishing failed. ErrPublishMessage = errors.New("failed to publish message") // ErrFailedSubscribe indicates that subscribing to a topic failed. ErrFailedSubscribe = errors.New("failed to subscribe") // ErrFailedUnsubscribe indicates that unsubscribing from a topic failed. ErrFailedUnsubscribe = errors.New("failed to unsubscribe") // ErrConnect indicates that connection to MQTT broker failed ErrConnect = errors.New("failed to connect to MQTT broker") // ErrPublishTimeout indicates that the publishing failed due to timeout. ErrPublishTimeout = errors.New("failed to publish due to timeout reached") // ErrSubscribeTimeout indicates that the subscription failed due to timeout. ErrSubscribeTimeout = errors.New("failed to subscribe due to timeout reached") // ErrUnsubscribeTimeout indicates that unsubscribe failed due to timeout. ErrUnsubscribeTimeout = errors.New("failed to unsubscribe due to timeout reached") // ErrUnsubscribeDeleteTopic indicates that unsubscribe failed because the topic was deleted. ErrUnsubscribeDeleteTopic = errors.New("failed to unsubscribe due to deletion of topic") // ErrNotSubscribed indicates that the topic is not subscribed to. ErrNotSubscribed = errors.New("not subscribed") // ErrEmptyTopic indicates the absence of topic. ErrEmptyTopic = errors.New("empty topic") // ErrMalformedSubtopic indicates that the subtopic is malformed. ErrMalformedSubtopic = errors.New("malformed subtopic") // ErrEmptyID indicates the absence of ID. ErrEmptyID = errors.New("empty ID") // ErrInvalidContentType indicates an invalid Content-Type ErrInvalidContentType = errors.New("invalid content type") )
Functions ¶
func FormatMessage ¶ added in v0.26.0
func FormatMessage(pc domain.PubConfigInfo, msg *protomfx.Message) error
func NormalizeSubtopic ¶ added in v0.35.0
func PayloadHash ¶ added in v0.42.0
func SplitMessage ¶ added in v0.28.0
Types ¶
type AlarmHandler ¶ added in v0.40.0
type AlarmHandler interface {
// Handle handles alarms passed by underlying implementation.
Handle(subject string, alarm protomfx.Alarm) error
// Cancel is used for cleanup during unsubscribing and it's optional.
Cancel() error
}
AlarmHandler represents protomfx.Alarm handler for AlarmSubscriber.
type AlarmPublisher ¶ added in v0.40.0
type AlarmPublisher interface {
// PublishAlarm publishes an alarm to the message broker.
PublishAlarm(subject string, alarm protomfx.Alarm) error
}
AlarmPublisher specifies the alarm publishing API.
type AlarmSubscriber ¶ added in v0.40.0
type AlarmSubscriber interface {
// SubscribeAlarms subscribes to the alarm stream.
SubscribeAlarms(id string, handler AlarmHandler) error
// UnsubscribeAlarms unsubscribes from the alarm stream.
UnsubscribeAlarms(id string) error
}
AlarmSubscriber specifies the alarm subscription API.
type CommandHandler ¶ added in v0.41.0
type CommandHandler interface {
// Handle handles commands passed by underlying implementation.
Handle(subject string, cmd protomfx.Command) error
// Cancel is used for cleanup during unsubscribing and it's optional.
Cancel() error
}
CommandHandler represents protomfx.Command handler for CommandSubscriber.
type CommandPublisher ¶ added in v0.41.0
type CommandPublisher interface {
// PublishCommand publishes a command to the message broker.
PublishCommand(subject string, cmd protomfx.Command) error
}
CommandPublisher specifies the command publishing API.
type CommandSubscriber ¶ added in v0.41.0
type CommandSubscriber interface {
// SubscribeCommands subscribes to the command stream for the given topic.
SubscribeCommands(id, topic string, handler CommandHandler) error
// UnsubscribeCommands unsubscribes from the command stream for the given topic.
UnsubscribeCommands(id, topic string) error
}
CommandSubscriber specifies the command subscription API.
type MessageDispatcher ¶ added in v0.42.0
type MessageDispatcher interface {
// Dispatch publishes msg to every subject enabled by the dispatcher flags in pc.
Dispatch(msg protomfx.Message, pc *domain.ProfileConfig) error
}
MessageDispatcher routes a message to every subject enabled by a profile's dispatcher flags.
type MessageHandler ¶
type MessageHandler interface {
// Handle handles messages passed by underlying implementation.
Handle(subject string, msg protomfx.Message) error
// Cancel is used for cleanup during unsubscribing and it's optional.
Cancel() error
}
MessageHandler represents protomfx.Message handler for Subscriber.
type NotificationHandler ¶ added in v0.42.0
type NotificationHandler interface {
// Handle handles notifications passed by underlying implementation.
Handle(subject string, notification protomfx.Notification) error
// Cancel is used for cleanup during unsubscribing and it's optional.
Cancel() error
}
NotificationHandler represents protomfx.Notification handler for NotificationSubscriber.
type NotificationPublisher ¶ added in v0.42.0
type NotificationPublisher interface {
// PublishNotification publishes a notification to the message broker.
PublishNotification(subject string, notification protomfx.Notification) error
}
NotificationPublisher specifies the notification publishing API.
type NotificationSubscriber ¶ added in v0.42.0
type NotificationSubscriber interface {
// SubscribeNotifications subscribes to the notification stream for the given topic.
SubscribeNotifications(id, topic string, handler NotificationHandler) error
// UnsubscribeNotifications unsubscribes from the notification stream for the given topic.
UnsubscribeNotifications(id, topic string) error
}
NotificationSubscriber specifies the notification subscription API.
type PubSub ¶
type PubSub interface {
Publisher
Subscriber
}
PubSub represents aggregation interface for publisher and subscriber.
type Publisher ¶
type Publisher interface {
// Publish publishes message to the message broker.
Publish(subject string, msg protomfx.Message) error
// Close gracefully closes message publisher's connection.
Close() error
}
Publisher specifies message publishing API.
type Subscriber ¶
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
}
Subscriber specifies message subscription API.
type WebhookHandler ¶ added in v0.42.0
type WebhookHandler interface {
// Handle handles webhook messages passed by underlying implementation.
Handle(subject string, webhook protomfx.Webhook) error
// Cancel is used for cleanup during unsubscribing and it's optional.
Cancel() error
}
WebhookHandler represents protomfx.Webhook handler for WebhookSubscriber.
type WebhookPublisher ¶ added in v0.42.0
type WebhookPublisher interface {
// PublishWebhook publishes a webhook message to the message broker.
PublishWebhook(subject string, webhook protomfx.Webhook) error
}
WebhookPublisher specifies the webhook publishing API.
type WebhookSubscriber ¶ added in v0.42.0
type WebhookSubscriber interface {
// SubscribeWebhooks subscribes to the webhook stream.
SubscribeWebhooks(id string, handler WebhookHandler) error
// UnsubscribeWebhooks unsubscribes from the webhook stream.
UnsubscribeWebhooks(id string) error
}
WebhookSubscriber specifies the webhook subscription API.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mqtt hold the implementation of the Publisher and PubSub interfaces for the MQTT messaging system, the internal messaging broker of the Mainflux IoT platform.
|
Package mqtt hold the implementation of the Publisher and PubSub interfaces for the MQTT messaging system, the internal messaging broker of the Mainflux IoT platform. |
|
Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Mainflux IoT platform.
|
Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Mainflux IoT platform. |