Skip to content

Commit

Permalink
Add logging for failed MQTT message handling
Browse files Browse the repository at this point in the history
Signed-off-by: Kate Goldenring <[email protected]>
  • Loading branch information
kate-goldenring committed Aug 2, 2024
1 parent fa32e53 commit cecc464
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ spin-expressions = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
spin-telemetry = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
tokio = { version = "1.37", features = ["full"] }
tracing = { version = "0.1", features = ["log"] }
paho-mqtt = { version = "0.12.3", features = [
"vendored-ssl",
] }
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ fn main() {
// Required for OpenSSL with musl
println!("cargo:rustc-link-arg=-lc");
}
}
}
16 changes: 10 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,16 @@ impl MqttTrigger {
match rx.recv().await {
Ok(Some(msg)) => {
// Handle the received message
self.handle_mqtt_event(
&component_id,
msg.payload().to_vec(),
msg.topic().to_owned(),
)
.await?;
if let Err(e) = self
.handle_mqtt_event(
&component_id,
msg.payload().to_vec(),
msg.topic().to_owned(),
)
.await
{
tracing::error!("Error handling MQTT message: {:?}", e);
}
}
Ok(None) => {
// Todo: Figure out what this case is
Expand Down

0 comments on commit cecc464

Please sign in to comment.