mqtt

package module
v0.0.0-...-89bbdfb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2022 License: Apache-2.0, BSD-3-Clause, MIT Imports: 15 Imported by: 0

README

MQTT

This trigger allows you to listen to messages on MQTT.

Installation

Flogo CLI
flogo install github.com/TIBCOSoftware/labs-air-contrib/trigger/mqtt

Configuration

Settings:
Name Type Description
broker string The broker URL - REQUIRED
id string The id of client - REQUIRED
username string The user's name
password string The user's password
store string The store for message persistence
cleanSession bool Clean session flag
keepAlive int Keep Alive time in seconds
autoReconnect bool Enable Auto-Reconnect
sslConfig object SSL configuration
sslConfig Object:
Property Type Description
skipVerify bool Skip SSL validation, defaults to true
useSystemCert bool Use the systems root certificate file, defaults to true
caFile string The path to PEM encoded root certificates file
certFile string The path to PEM encoded client certificate
keyFile string The path to PEM encoded client key

Note: used if broker URI is ssl

Handler Settings
Name Type Description
topic string The topic to listen on - REQUIRED
replyTopic string The topic to reply on
qos int The Quality of Service
retain bool Retain Messages
Topics

MQTT wildcard syntax is supported. For example if the topic is '/x/+/y/#' then the topicParams output will be populated with the wildcard values. The first wildcard will be in topicParams with key '0' and the second with key '1'. Topic wildcards can also be given a name: '/x/+param1/y/#param2'. Then the names 'param1' and 'param2' can be used to access the wildcards in the topicParams output.

Output:
Name Type Description
message string The message received
topic string The MQTT topic
topicParams params The topic parameters
Reply:
Name Type Description
data object The data recieved

Example

{
  "id": "mqtt-trigger",
  "name": "Mqtt Trigger",
  "ref": "github.com/TIBCOSoftware/labs-air-contrib/trigger/mqtt",
  "settings": {
      "broker" : "tcp://localhost:1883",
     	"id":"client-1"
  },
  "handlers": {
    "settings": {
    	"topic": "flogo",
    	"qos": "0"
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
}

func (*Factory) Metadata

func (*Factory) Metadata() *trigger.Metadata

func (*Factory) New

func (*Factory) New(config *trigger.Config) (trigger.Trigger, error)

New implements trigger.Factory.New

type HandlerSettings

type HandlerSettings struct {
	Topic        string `md:"topic,required"` // The topic to listen on
	ReplyTopic   string `md:"replyTopic"`     // The topic to reply on
	Qos          int    `md:"qos"`            // The Quality of Service
	Retain       bool   `md:"retain"`         // Retain messages
	Deserializer string `md:"deserializer"`   // Content deserialization
}

type Output

type Output struct {
	Id          string                 `md:"id"`          // The id of client
	Content     interface{}            `md:"content"`     // The content of the json message recieved
	Topic       string                 `md:"topic"`       // The MQTT topic
	TopicParams map[string]interface{} `md:"topicParams"` // The topic parameters
}

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

type Reply

type Reply struct {
	Data interface{} `md:"data"` // The data to reply with
}

func (*Reply) FromMap

func (r *Reply) FromMap(values map[string]interface{}) error

func (*Reply) ToMap

func (r *Reply) ToMap() map[string]interface{}

type Settings

type Settings struct {
	Broker        string                 `md:"broker,required"` // The broker URL
	Id            string                 `md:"id,required"`     // The id of client
	Username      string                 `md:"username"`        // The user's name
	Password      string                 `md:"password"`        // The user's password
	Store         string                 `md:"store"`           // The store for message persistence
	CleanSession  bool                   `md:"cleanSession"`    // Clean session flag
	KeepAlive     int                    `md:"keepAlive"`       // Keep Alive time in seconds
	AutoReconnect bool                   `md:"autoReconnect"`   // Enable Auto-Reconnect
	SSLConfig     map[string]interface{} `md:"sslConfig"`       // SSL Configuration
}

type Token

type Token struct {
	TokenType TokenType
	Token     string
}

Token is a MQTT topic token

type TokenType

type TokenType int

TokenType is a type of token

const (
	// Literal is a literal token type
	Literal TokenType = iota
	// SingleLevel is a single level wildcard
	SingleLevel
	// MultiLevel is a multi level wildcard
	MultiLevel
)

type Topic

type Topic []Token

Topic is a parsed topic

func ParseTopic

func ParseTopic(topic string) Topic

ParseTopic parses the topic

func (Topic) Match

func (t Topic) Match(input Topic) map[string]string

Match matches the topic with an input topic

func (Topic) String

func (t Topic) String() string

String generates a string for the topic

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

Trigger is simple MQTT trigger

func (*Trigger) Initialize

func (t *Trigger) Initialize(ctx trigger.InitContext) error

Initialize implements trigger.Initializable.Initialize

func (*Trigger) Start

func (t *Trigger) Start() error

Start implements trigger.Trigger.Start

func (*Trigger) Stop

func (t *Trigger) Stop() error

Stop implements ext.Trigger.Stop

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL