Skip to content

Commit

Permalink
clarify docs for RunningSaga::wait_until_stopped() (#5974)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Jun 29, 2024
1 parent f275827 commit 680757d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions nexus/src/app/saga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,22 @@ pub(crate) struct RunningSaga {
}

impl RunningSaga {
/// Waits until this saga stops executing
/// Waits until the saga stops executing
///
/// Normally, the saga will have finished successfully or failed and unwound
/// completely. If unwinding fails, it will be _stuck_ instead.
/// This function waits until the saga stops executing because one of the
/// following three things happens:
///
/// 1. The saga completes successfully
/// ([`nexus_types::internal_api::views::SagaState::Succeeded`]).
/// 2. The saga fails and unwinding completes without errors
/// ([`nexus_types::internal_api::views::SagaState::Failed`]).
/// 3. The saga fails and then an error is encountered during unwinding
/// ([`nexus_types::internal_api::views::SagaState::Stuck`]).
///
/// Steno continues running the saga (and this function continues waiting)
/// until one of those three things happens. Once any of those things
/// happens, the saga is no longer running and this function returns a
/// `StoppedSaga` that you can use to inspect more precisely what happened.
pub(crate) async fn wait_until_stopped(self) -> StoppedSaga {
let result = self.saga_completion_future.await;
info!(self.log, "saga finished"; "saga_result" => ?result);
Expand Down

0 comments on commit 680757d

Please sign in to comment.