Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
AddToSchema = configBuilder.AddToSchema
)
var ConnectionConfigSpec = conf.SectionSpec{ { Name: "Name", Type: conf.StringType, Description: "The name of the connection mainly used in references.", Required: true, }, { Name: "Server", Type: conf.StringSliceType, Description: "Mqtt server address", Required: true, }, { Name: "ClientID", Type: conf.StringType, Description: "Client ID for MQTT. A random ID will be created for each connection if left empty.", }, { Name: "KeepAliveSeconds", Type: conf.IntType, Description: "Number of seconds for MQTT keep-alive", Default: "60", }, { Name: "User", Type: conf.StringType, Description: "Username for MQTT server", }, { Name: "Password", Type: conf.StringType, Description: "Password for MQTT server", Annotations: new(conf.Annotation).With( conf.SecretValue(), ), }, }
ConnectionConfigSpec defines all allowed MQTT configuration stanzas.
var DefaultConnectionManager = NewConnectionManager(runtime.GlobalSchema)
DefaultConnectionManager is the default connection manager that keeps track of configured and established MQTT connections. Note that the DefaultConnectionManager is bound to runtime.GlobalSchema!
var TriggerSpec = conf.SectionSpec{ { Name: "ConnectionName", Description: "The name of the MQTT connection configuration. Defaults to the first configuration.", Type: conf.StringType, Annotations: new(conf.Annotation).With( runtime.OneOfRef("MQTT", "Name", "Name"), ), }, { Name: "TopicPrefix", Description: "Prefix for the event topic", Type: conf.StringType, Aliases: []string{"Topic"}, }, { Name: "EventAsTopic", Description: "Whether or not the event ID is used as a topic. If false, TopicPrefix or Topic must be set.", Type: conf.BoolType, Default: "yes", }, { Name: "QualityOfService", Description: "The QoS to use when publishing messages", Type: conf.IntType, Default: "0", }, }
Functions ¶
func AddTriggerType ¶
func AddTriggerType(reg *trigger.Registry, connectionManager *ConnectionManager) error
AddTriggerType registers the MQTT trigger on the registry reg.
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct { Name string Server []string ClientID string KeepAliveSeconds int User string Password string }
ConnectionConfig groups all MQTT related configuration settings.
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager(cs *runtime.ConfigSchema) *ConnectionManager
NewConnectionManager returns a new MQTT connection manager.
func (*ConnectionManager) ClientWithRandomID ¶
ClientWithRandomID returns a new, connected MQTT client created from the configration identified by name. The ID of the client is a random string to not interfer with other instances of the above configuration.
type EventPublisher ¶
type EventPublisher struct { ConnectionName string TopicPrefix string EventAsTopic bool QualityOfService int // contains filtered or unexported fields }
func (*EventPublisher) HandleEvents ¶
HandleEvent implements (event.Handler).