Skip to content

Commit

Permalink
fix: only exist ordering loop on fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dav1do committed Dec 3, 2024
1 parent 7ca8ed0 commit ee59405
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions event-svc/src/event/ordering_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,12 @@ impl OrderingTask {
trace!(?recon_events, "new events discovered!");
state.add_inserted_events(recon_events);

if state
if let Err(_should_exit) = state
.process_streams(Arc::clone(&event_access))
.await
.map_err(Self::log_error)
.is_err()
{
warn!("Ordering task exiting due to fatal error");
return;
error!("Ordering task exiting due to fatal error.");
}
}
}
Expand All @@ -120,20 +118,20 @@ impl OrderingTask {
.map_err(Self::log_error);
}

/// Log an error and return a result that can be used to stop the task if it was fatal
fn log_error(err: Error) -> std::result::Result<(), ()> {
/// Log an error and return a true if it was fatal
fn log_error(err: Error) -> bool {
match err {
Error::Application { error } => {
warn!("Encountered application error: {:?}", error);
Ok(())
false
}
Error::Fatal { error } => {
error!("Encountered fatal error: {:?}", error);
Err(())
true
}
Error::Transient { error } | Error::InvalidArgument { error } => {
info!("Encountered error: {:?}", error);
Ok(())
false
}
}
}
Expand Down

0 comments on commit ee59405

Please sign in to comment.