Skip to content

Commit

Permalink
stopping is error
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Jan 8, 2025
1 parent a466bf4 commit 011ce60
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/aspen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,11 +847,21 @@ async fn main() -> anyhow::Result<()> {
}
}

async fn flatten_stopping_is_err<T>(
handle: tokio::task::JoinHandle<Result<T, Box<dyn Error + Sync + Send>>>,
) -> Result<T, Box<dyn Error + Sync + Send>> {
match handle.await {
Ok(Ok(result)) => panic!("Stopping wasn't supposed to happen!"),
Ok(Err(err)) => Err(err),
Err(err) => Err(Box::new(err)),
}
}

let result_series = tokio::try_join!(
flatten(leader_thread_handler),
flatten(async_from_alpenrose_processor_handler),
flatten(tarpc_server),
flatten(etcd_lease_renewer)
flatten_stopping_is_err(leader_thread_handler),
flatten_stopping_is_err(async_from_alpenrose_processor_handler),
flatten_stopping_is_err(tarpc_server),
flatten_stopping_is_err(etcd_lease_renewer)
)
.unwrap();

Expand Down

0 comments on commit 011ce60

Please sign in to comment.