Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSink ¶
NewSink returns a sink as MQTT publisher. To publish a message, a tuple inserted into the sink needs to have two fields: "topic" and "payload". There is also one optional field: "qos", that should contain MQTT qos to publish message with:
{
"topic": "foo/bar",
"payload": "any form of data including JSON encoded in string",
"qos": 1
}
In the case above, the topic of the message is "foo/bar" and the QoS is increased to 1 meaing message must be delivered at least once. The field names of topic and payload can be changed by setting topic_field, payload_field and qos_field parameters, respectively. When a payload needs is a string or a blob, it's directly sent to a broker. The payload can also be an array or a map, and it will be sent as JSON.
The sink has following optional parameters:
- broker: the address of the broker in URI "schema://host:port" format (default: "tcp://127.0.0.1:1883")
- user: the user name to be connected (default: "")
- password: the password of the user (default: "")
- payload_field: the field name in tuples having a payload (default: "payload")
- topic_field: the field name in tuples having a topic (default: "")
- default_topic: the default topic used when a tuple doesn't have topic_field (default: "")
- default_qos: the default to publish tuples with, can be 0, 1 or 2 (default: 0)
func NewSource ¶
NewSource create a new Source receiving data from a MQTT broker. The source emits tuples like;
{
"topic": "foo/bar",
"payload": <blob>
}
The topic field has topic of the message and the payload field has data as a blob. If the data contains JSON and a user wants to manipulate it, another stream needs to be created:
CREATE STREAM hoge AS SELECT RSTREAM decode_json(payload) AS * FROM mqtt_src [RANGE 1 TUPLES];
The source has following required parameters:
- topic: the topic to be subscribed
The source has following optional parameters:
- broker: the address of the broker in URI schema://"host:port" format (default: "tcp://127.0.0.1:1883")
- user: the user name to be connected (default: "")
- password: the password of the user (default: "")
- reconnect_min_time: minimal time to wait before reconnecting in Go duration format (default: 1s)
- reconnect_max_time: maximal time to wait before reconnecting in Go duration format (default: 30s)
Types ¶
This section is empty.