pub struct ErrorClassificationMiddleware { /* private fields */ }Expand description
Error classification middleware for intelligent error routing
This middleware classifies errors into categories and can route messages to different queues based on error type (e.g., transient vs permanent errors).
§Examples
use celers_kombu::ErrorClassificationMiddleware;
let classifier = ErrorClassificationMiddleware::new()
.with_transient_pattern("timeout|connection")
.with_permanent_pattern("validation|schema")
.with_max_transient_retries(5);Implementations§
Source§impl ErrorClassificationMiddleware
impl ErrorClassificationMiddleware
Sourcepub fn with_transient_pattern(self, pattern: &str) -> Self
pub fn with_transient_pattern(self, pattern: &str) -> Self
Add a pattern for transient errors (can be retried)
Sourcepub fn with_permanent_pattern(self, pattern: &str) -> Self
pub fn with_permanent_pattern(self, pattern: &str) -> Self
Add a pattern for permanent errors (should not be retried)
Sourcepub fn with_max_transient_retries(self, max_retries: u32) -> Self
pub fn with_max_transient_retries(self, max_retries: u32) -> Self
Set maximum retries for transient errors
Sourcepub fn with_max_permanent_retries(self, max_retries: u32) -> Self
pub fn with_max_permanent_retries(self, max_retries: u32) -> Self
Set maximum retries for permanent errors
Sourcepub fn classify_error(&self, error_msg: &str) -> ErrorClass
pub fn classify_error(&self, error_msg: &str) -> ErrorClass
Classify an error message
Sourcepub fn should_retry(&self, error_msg: &str, current_retries: u32) -> bool
pub fn should_retry(&self, error_msg: &str, current_retries: u32) -> bool
Determine if a message should be retried based on error classification
Trait Implementations§
Source§impl MessageMiddleware for ErrorClassificationMiddleware
impl MessageMiddleware for ErrorClassificationMiddleware
Source§fn before_publish<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 mut Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_publish<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 mut Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process message before publishing
Auto Trait Implementations§
impl Freeze for ErrorClassificationMiddleware
impl RefUnwindSafe for ErrorClassificationMiddleware
impl Send for ErrorClassificationMiddleware
impl Sync for ErrorClassificationMiddleware
impl Unpin for ErrorClassificationMiddleware
impl UnsafeUnpin for ErrorClassificationMiddleware
impl UnwindSafe for ErrorClassificationMiddleware
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