Crates.io | cerk_port_mqtt |
lib.rs | cerk_port_mqtt |
version | 0.2.11 |
source | src |
created_at | 2020-11-23 16:26:29.48354 |
updated_at | 2021-01-09 17:51:22.338744 |
description | This is a package for CERK. CERK is an open source CloudEvents Router written in Rust with a MicroKernel architecture. |
homepage | https://github.com/ce-rust/cerk |
repository | https://github.com/ce-rust/cerk |
max_upload_size | |
id | 315448 |
size | 25,374 |
This is a package for CERK. CERK is an open source CloudEvents Router written in Rust with a MicroKernel architecture.
CERK lets you route your CloudEvents between different different ports. Ports are transport layer bindings over which CloudEvents can be exchanged. It is built with modularity and portability in mind.
CERK comes with a couple of prefabricated components, but implementing custom components is easy.
A good overview is provided on GitHub.
This port publishes and/or subscribe CloudEvents to/from an MQTT v3.1 topic.
The port is implemented with a Eclipse Paho MQTT Rust Client and sends and receives messages according to the MQTT Protocol Binding for CloudEvents v1.0 specification
The configurations should be of type cerk::kernel::Config::HashMap
and have at least the entires:
The value has to by of type Config::String
and contain a host name with protocol and port.
E.g. Config::String(String::from("tcp://mqtt-broker:1883"))
The value has to by of type Config::String
and contain the MQTT topic name where the message will be sent to.
E.g. Config::String(String::from("test"))
The following configurations are optional.
The value has to by of type Config::U8
and contain one of the following values.
The values are defined according to the Eclipse Paho MQTT Rust Client PersistenceType.
E.g. Config::U8(0)
The quality of service for message delivery. The quality of service is only for the MQTT broker and does not change any behavior of the router or the port. The router only supports best effort at the moment.
E.g. Config::U8(0)
The value has to by of type Config::Vec([Config::String])
and must have the same length as subscribe_qos
.
The values in the vector contain the MQTT topic wich the router should subscribe to.
If multiple topics are subscribed in the same MQTT port, there is no possibility at the moment to know let the router or the output port know from which topic the event was received.
The value has to by of type Config::Vec([Config::U8])
and must have the same length as subscribe_topics
.
The quality of service for the topic subscription. The quality of service is only for the MQTT broker and does not change any behavior of the router or the port. The router only supports best effort at the moment.
This configuration will connect to the broker but will not send or receive any events.
use std::collections::HashMap;
use cerk::kernel::Config;
let map: HashMap<String, Config> = [
("host".to_string(), Config::String("tcp://mqtt-broker:1883".to_string())),
]
.iter()
.cloned()
.collect();
let config = Config::HashMap(map);
use std::collections::HashMap;
use cerk::kernel::Config;
let map: HashMap<String, Config> = [
("host".to_string(), Config::String("tcp://mqtt-broker:1883".to_string())),
("persistence".to_string(), Config::U8(0)),
("send_topic".to_string(), Config::String("test".to_string())),
("send_qos".to_string(), Config::U8(2)),
]
.iter()
.cloned()
.collect();
let config = Config::HashMap(map);
use std::collections::HashMap;
use cerk::kernel::Config;
let map: HashMap<String, Config> = [
("host".to_string(), Config::String("tcp://mqtt-broker:1883".to_string())),
("persistence".to_string(), Config::U8(0)),
(
"subscribe_topics".to_string(),
Config::Vec(vec![Config::String("test".to_string())]),
),
(
"subscribe_qos".to_string(),
Config::Vec(vec![Config::U8(2)]),
),
]
.iter()
.cloned()
.collect();
let config = Config::HashMap(map);
use std::collections::HashMap;
use cerk::kernel::Config;
let map: HashMap<String, Config> = [
("host".to_string(), Config::String("tcp://mqtt-broker:1883".to_string())),
("persistence".to_string(), Config::U8(0)),
("send_topic".to_string(), Config::String("test".to_string())),
("send_qos".to_string(), Config::U8(2)),
(
"subscribe_topics".to_string(),
Config::Vec(vec![Config::String("test".to_string())]),
),
(
"subscribe_qos".to_string(),
Config::Vec(vec![Config::U8(2)]),
),
]
.iter()
.cloned()
.collect();
let config = Config::HashMap(map);
reliability this port does not support any DeliveryGuarantee
other then BestEffort
and so does never send a OutgoingCloudEventProcessed
or IncomingCloudEventProcessed
messages
The original readme text is a Rust doc comment in the lib.rs file
cargo install cargo-readme
cargo readme > README.md
Apache-2.0