Skip to content

Commit

Permalink
Observer errors are now fatal (#913)
Browse files Browse the repository at this point in the history
* Print errors from observer rather than silently swallowing them

* Observer errors now cause lading to exit
  • Loading branch information
scottopell authored Jul 11, 2024
1 parent 9711239 commit eca9cdd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lading/src/bin/lading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,15 @@ async fn inner_main(
}

let mut tsrv_joinset = tokio::task::JoinSet::new();
let mut osrv_joinset = tokio::task::JoinSet::new();
//
// OBSERVER
//
// Observer is not used when there is no target.
if let Some(target) = config.target {
let obs_rcv = tgt_snd.subscribe();
let observer_server = observer::Server::new(config.observer, shutdown.clone())?;
let _osrv = tokio::spawn(observer_server.run(obs_rcv));
osrv_joinset.spawn(observer_server.run(obs_rcv));

//
// TARGET
Expand Down Expand Up @@ -504,6 +505,19 @@ async fn inner_main(
info!("shutdown signal received.");
break Ok(());
}
Some(res) = osrv_joinset.join_next() => {
match res {
Ok(observer_result) => match observer_result {
Ok(()) => { /* Observer shut down successfully */ }
Err(err) => {
error!("Observer shut down unexpectedly: {err}");
shutdown.signal();
break Err(Error::LadingObserver(err));
}
}
Err(err) => error!("Could not join the spawned observer task: {}", err),
}
},
Some(res) = gsrv_joinset.join_next() => {
match res {
Ok(generator_result) => match generator_result {
Expand Down

0 comments on commit eca9cdd

Please sign in to comment.