pub enum FailureStrategy {
Fatal,
Skip,
Retry,
}Expand description
Strategy for handling event processing failures.
When a projector’s apply() method returns an error, the on_error()
callback determines how the projection runner should respond. This enum
represents the available failure strategies.
§Variants
Fatal: Stop processing immediately and return the errorSkip: Log the error and continue processing the next eventRetry: Attempt to reprocess the event according to retry configuration
§Example
ⓘ
fn on_error(
&mut self,
ctx: FailureContext<Self::Error>,
) -> FailureStrategy {
match ctx.error {
MyError::Transient(_) if ctx.retry_count < 3 => FailureStrategy::Retry,
MyError::PoisonEvent(_) => FailureStrategy::Skip,
_ => FailureStrategy::Fatal,
}
}Variants§
Fatal
Stop processing immediately and return the error to the caller.
Use this when:
- The error is unrecoverable (e.g., database schema mismatch)
- The projector requires manual intervention
- Continuing would corrupt the read model
Skip
Skip this event and continue processing the next one.
Use this when:
- The event is malformed or invalid (poison event)
- Processing this event is not critical
- Continuing without this event is acceptable
Retry
Retry processing this event according to retry configuration.
Use this when:
- The error is likely transient (e.g., network timeout)
- Retrying might succeed
- The event is important and should not be skipped
Trait Implementations§
Source§impl Clone for FailureStrategy
impl Clone for FailureStrategy
Source§fn clone(&self) -> FailureStrategy
fn clone(&self) -> FailureStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FailureStrategy
impl Debug for FailureStrategy
Source§impl PartialEq for FailureStrategy
impl PartialEq for FailureStrategy
impl Copy for FailureStrategy
impl Eq for FailureStrategy
impl StructuralPartialEq for FailureStrategy
Auto Trait Implementations§
impl Freeze for FailureStrategy
impl RefUnwindSafe for FailureStrategy
impl Send for FailureStrategy
impl Sync for FailureStrategy
impl Unpin for FailureStrategy
impl UnsafeUnpin for FailureStrategy
impl UnwindSafe for FailureStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more