pub enum ErrorStrategy<T: Debug + Clone + Send + Sync> {
Stop,
Skip,
Retry(usize),
Custom(Arc<dyn Fn(&StreamError<T>) -> ErrorAction + Send + Sync>),
}Expand description
Strategy for handling errors in pipeline components.
Error strategies determine how components respond to errors during stream processing. Strategies can be set at the pipeline level or overridden at the component level.
§Example
use streamweave::error::ErrorStrategy;
// Stop on first error (default)
let strategy = ErrorStrategy::Stop;
// Skip errors and continue
let strategy = ErrorStrategy::Skip;
// Retry up to 3 times
let strategy = ErrorStrategy::Retry(3);
// Custom error handling
let strategy = ErrorStrategy::new_custom(|error| {
if error.retries < 2 {
ErrorAction::Retry
} else {
ErrorAction::Stop
}
});Variants§
Stop
Stop processing immediately when an error occurs.
This is the default strategy and ensures data integrity.
Skip
Skip items that cause errors and continue processing.
Useful for data cleaning scenarios where invalid records can be safely ignored.
Retry(usize)
Retry failed operations up to the specified number of times.
§Arguments
usize- Maximum number of retry attempts
Useful for transient failures like network timeouts.
Custom(Arc<dyn Fn(&StreamError<T>) -> ErrorAction + Send + Sync>)
Custom error handling logic.
Allows fine-grained control over error handling based on error context, type, or retry count.
Implementations§
Source§impl<T: Debug + Clone + Send + Sync> ErrorStrategy<T>
impl<T: Debug + Clone + Send + Sync> ErrorStrategy<T>
Sourcepub fn new_custom<F>(f: F) -> Self
pub fn new_custom<F>(f: F) -> Self
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ErrorStrategy<T>
impl<T> !RefUnwindSafe for ErrorStrategy<T>
impl<T> Send for ErrorStrategy<T>
impl<T> Sync for ErrorStrategy<T>
impl<T> Unpin for ErrorStrategy<T>
impl<T> !UnwindSafe for ErrorStrategy<T>
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