Documentation
¶
Overview ¶
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. Due to the practical requirements implementation Publisher is created alongside PubSub. The reason for this is that Subscriber implementation of NATS brings the burden of additional struct fields which are not used by Publisher. Subscriber is not implemented separately because PubSub can be used where Subscriber is needed.
Index ¶
- Constants
- func GetGroupCommandsSubject(groupID, subtopic string) string
- func GetMessagesSubject(thingID, subtopic string) string
- func GetPublishSubjects(thingID, subtopic string, pc *domain.ProfileConfig) []string
- func GetThingCommandsSubject(thingID, subtopic string) string
- type PubSub
- type Publisher
Constants ¶
const ( // SubjectThings represents the wildcard subject covering all thing subjects. SubjectThings = "things.>" // SubjectGroups represents the wildcard subject covering all group subjects. SubjectGroups = "groups.>" // SubjectMessages represents subject used to subscribe to the global message stream. SubjectMessages = "things.*.messages" // SubjectMessagesWithSubtopic represents subject used to subscribe to the global message stream with subtopic. SubjectMessagesWithSubtopic = "things.*.messages.>" // SubjectThingCommands represents subject used to subscribe to thing commands. SubjectThingCommands = "things.*.commands" // SubjectThingCommandsWithSubtopic represents subject used to subscribe to thing commands with subtopic. SubjectThingCommandsWithSubtopic = "things.*.commands.>" // SubjectGroupCommands represents subject used to subscribe to group commands. SubjectGroupCommands = "groups.*.commands" // SubjectGroupCommandsWithSubtopic represents subject used to subscribe to group commands with subtopic. SubjectGroupCommandsWithSubtopic = "groups.*.commands.>" // SubjectSmtp represents subject used to subscribe to SMTP notifications. SubjectSmtp = "smtp.*" // SubjectSmpp represents subject used to subscribe to SMPP notifications. SubjectSmpp = "smpp.*" // SubjectAlarms represents subject used to subscribe to alarm triggers. SubjectAlarms = "alarms.*" // SubjectWebhooks represents subject used to subscribe to webhook forwarding — both rule-triggered and integration-based. SubjectWebhooks = "webhooks" // SubjectRules represents subject used to route messages to the rules service. SubjectRules = "rules" )
Variables ¶
This section is empty.
Functions ¶
func GetGroupCommandsSubject ¶ added in v0.35.0
func GetMessagesSubject ¶ added in v0.35.0
func GetPublishSubjects ¶ added in v0.41.0
func GetPublishSubjects(thingID, subtopic string, pc *domain.ProfileConfig) []string
GetPublishSubjects returns the NATS subjects a message should be published to based on the dispatcher flags in the profile config.
func GetThingCommandsSubject ¶ added in v0.35.0
Types ¶
type PubSub ¶ added in v0.40.0
type PubSub interface {
messaging.PubSub
messaging.AlarmPublisher
messaging.AlarmSubscriber
messaging.CommandPublisher
messaging.CommandSubscriber
}
PubSub extends messaging.PubSub with alarm/command publishing, and alarm/command subscribing.
func NewPubSub ¶
NewPubSub returns NATS message publisher/subscriber. Parameter queue specifies the queue for the Subscribe method. If queue is specified (is not an empty string), Subscribe method will execute NATS QueueSubscribe which is conceptually different from ordinary subscribe. For more information, please take a look here: https://docs.nats.io/developing-with-nats/receiving/queues. If the queue is empty, Subscribe will be used.
type Publisher ¶ added in v0.40.0
type Publisher interface {
messaging.Publisher
messaging.AlarmPublisher
messaging.CommandPublisher
}
Publisher extends the base messaging.Publisher with alarm and command publishing capabilities.
func NewPublisher ¶
NewPublisher returns NATS message Publisher.