aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2025-07-04 12:55:32 +0200
committerTomasz Kramkowski <tomasz@kramkow.ski>2025-07-04 12:55:32 +0200
commit68839f01cd982f03d7ff95d3180cfae8534dc3eb (patch)
treee6220aa6035cdbf13905d4f479cdd07d700b3dc1 /src/main.rs
parentce71a662f977c9dd3790c62620ebd0568276b05f (diff)
downloadmqttr-68839f01cd982f03d7ff95d3180cfae8534dc3eb.tar.gz
mqttr-68839f01cd982f03d7ff95d3180cfae8534dc3eb.tar.xz
mqttr-68839f01cd982f03d7ff95d3180cfae8534dc3eb.zip
Configurable QoS
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 0ba13f4..84ee406 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -73,9 +73,8 @@ async fn main() -> anyhow::Result<()> {
let conf = config::load(&conf_path)
.with_context(|| format!("Failed to load config: {:?}", &conf_path))?;
let (client, mut event_loop) = conf.mqtt_client();
- for topic in conf.routes.keys() {
- // TODO: Configurable subscription QoS
- if let Err(e) = client.subscribe(topic, QoS::ExactlyOnce).await {
+ for (topic, route) in conf.routes.iter() {
+ if let Err(e) = client.subscribe(topic, route.qos.unwrap_or(conf.qos)).await {
eprintln!("warning: Failed to subscribe to '{topic}': {e:?}");
}
}
@@ -83,11 +82,11 @@ async fn main() -> anyhow::Result<()> {
let notification = event_loop.poll().await;
match notification? {
Incoming(Packet::Publish(p)) => {
- for (topic, programs) in conf.routes.iter() {
+ for (topic, route) in conf.routes.iter() {
if !topic_match(&topic, &p.topic) {
continue;
}
- for program in programs {
+ for program in &route.programs {
// TODO: Switch to moro_local to avoid this ewwyness
let program = program.clone();
let p = p.clone();