Documentation
¶
Index ¶
- Constants
- func ConnectorFactory(URL url.URL) (mqhub.Connector, error)
- func Encode(msg mqhub.Message) ([]byte, error)
- func EndpointTopic(topicBase, name string) string
- func ParseTopic(topic, prefix string) (compID, endpoint string)
- func ParseTopicRel(relativeTopic string) (compID, endpoint string)
- func SubCompTopic(topicBase string, id ...string) string
- func TokenizeTopic(topic string) []string
- type Connector
- type DataEmitter
- type DataSink
- type Descriptor
- type EndpointRef
- type Future
- type HandlerRef
- type Message
- type Options
- type Publication
- type TopicFilter
- type TopicHandlerMap
Constants ¶
const ( // Protocol is the name of protocol for connector Protocol = "mqtt" // OptClientID is the property name in URL query OptClientID = "client-id" )
Variables ¶
This section is empty.
Functions ¶
func ConnectorFactory ¶
ConnectorFactory implements mqhub.ConnectorFactory
func EndpointTopic ¶
EndpointTopic creates a topic for endpoints
func ParseTopic ¶
ParseTopic parse topic including the prefix
func ParseTopicRel ¶
ParseTopicRel parse topic without prefix (start with component ID)
func SubCompTopic ¶
SubCompTopic creates a topic for sub-components
func TokenizeTopic ¶
TokenizeTopic split topic into tokens
Types ¶
type Connector ¶
Connector connects to MQTT
func (*Connector) Describe ¶
func (c *Connector) Describe(componentID string) mqhub.Descriptor
Describe creates a descriptor
type DataEmitter ¶
type DataEmitter struct {
// contains filtered or unexported fields
}
DataEmitter is a consumer which publish the data to hub
func (*DataEmitter) ConsumeMessage ¶
func (e *DataEmitter) ConsumeMessage(msg mqhub.Message) mqhub.Future
ConsumeMessage emits the message
type DataSink ¶
type DataSink struct {
// contains filtered or unexported fields
}
DataSink is a consumer receives messages from hub
type Descriptor ¶
type Descriptor struct { ComponentID string `json:"id"` SubTopic string `json:"topic"` // contains filtered or unexported fields }
Descriptor represents advertisements and implements mqhub.Descriptor
func (*Descriptor) Endpoint ¶
func (d *Descriptor) Endpoint(name string) mqhub.EndpointRef
Endpoint implements Descriptor
func (*Descriptor) SubComponent ¶
func (d *Descriptor) SubComponent(id ...string) mqhub.Descriptor
SubComponent implements Descriptor
func (*Descriptor) Watch ¶
func (d *Descriptor) Watch(sink mqhub.MessageSink) (mqhub.Watcher, error)
Watch implements Descriptor
type EndpointRef ¶
type EndpointRef struct {
// contains filtered or unexported fields
}
EndpointRef implements mqhub.EndpointRef
func (*EndpointRef) ConsumeMessage ¶
func (r *EndpointRef) ConsumeMessage(msg mqhub.Message) mqhub.Future
ConsumeMessage implements MessageSink
func (*EndpointRef) Watch ¶
func (r *EndpointRef) Watch(sink mqhub.MessageSink) (mqhub.Watcher, error)
Watch implements EndpointRef
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future implements mqhub.Future
type HandlerRef ¶
type HandlerRef struct {
Handler paho.MessageHandler
}
HandlerRef wraps over a handler
func MakeHandlerRef ¶
func MakeHandlerRef(handler paho.MessageHandler) *HandlerRef
MakeHandlerRef builds a HandlerRef
type Message ¶
Message implements Message
func NewMessage ¶
NewMessage wraps mqtt message
type Options ¶
type Options struct { Servers []*url.URL TLS tls.Config Username string Password string ClientID string Namespace string }
Options defines configuration for connection
func (*Options) SetClientID ¶
SetClientID sets client ID
type Publication ¶
type Publication struct {
// contains filtered or unexported fields
}
Publication implements mqhub.Publication
func (*Publication) Component ¶
func (p *Publication) Component() mqhub.Component
Component implements Publication
type TopicFilter ¶
type TopicFilter struct {
// contains filtered or unexported fields
}
TopicFilter defines a parsed topic filter
func NewTopicFilter ¶
func NewTopicFilter(filter string) *TopicFilter
NewTopicFilter parses a topic filter in string
func (*TopicFilter) Matches ¶
func (f *TopicFilter) Matches(topic string) bool
Matches indicates f matches the topic
func (*TopicFilter) MatchesTokenized ¶
func (f *TopicFilter) MatchesTokenized(tokens []string) bool
MatchesTokenized indicates f matches the tokenized topic
func (*TopicFilter) String ¶
func (f *TopicFilter) String() string
String returns the filter in string
type TopicHandlerMap ¶
type TopicHandlerMap struct {
// contains filtered or unexported fields
}
TopicHandlerMap maps topic filter to handlers
func NewTopicHandlerMap ¶
func NewTopicHandlerMap() *TopicHandlerMap
NewTopicHandlerMap creates a new TopicHandlerMap
func (*TopicHandlerMap) Add ¶
func (m *TopicHandlerMap) Add(filters []string, handler *HandlerRef) (subs []string)
Add inserts filters and corresponding handler the returns subs require a SUBSCRIBE
func (*TopicHandlerMap) Del ¶
func (m *TopicHandlerMap) Del(filters []string, handler *HandlerRef) (unsubs []string)
Del removes filters/handler, the returned topics require UNSUBSCRIBE
func (*TopicHandlerMap) HandleMessage ¶
func (m *TopicHandlerMap) HandleMessage(client paho.Client, msg paho.Message)
HandleMessage implements paho.MessageHandler