Skip to content

Commit

Permalink
Refactor bridge for better visibility when waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
jarhodes314 committed Jul 25, 2024
1 parent 710cead commit 00be96e
Show file tree
Hide file tree
Showing 5 changed files with 648 additions and 138 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 crates/extensions/tedge_mqtt_bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ certificate = { workspace = true }
futures = { workspace = true }
mqtt_channel = { workspace = true }
mutants = { workspace = true }
pin-project = { workspace = true }
rumqttc = { workspace = true }
tedge_actors = { workspace = true }
tedge_config = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion crates/extensions/tedge_mqtt_bridge/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type NotificationRes = Result<Event, ConnectionError>;
/// A client for [BridgeHealthMonitor]
///
/// This is used by each bridge half to log and notify the monitor of health status updates
#[derive(Debug)]
pub struct BridgeHealth {
name: &'static str,
tx_health: mpsc::Sender<(&'static str, Status)>,
Expand Down Expand Up @@ -104,7 +105,8 @@ impl BridgeHealth {
}
self.last_err = err;
let status = self.last_err.as_ref().map_or(Status::Up, |_| Status::Down);
self.tx_health.send((name, status)).await.unwrap()
let mut tx_health = self.tx_health.clone();
tokio::spawn(async move { tx_health.send((name, status)).await.unwrap() });
}
}
}
Loading

0 comments on commit 00be96e

Please sign in to comment.