pub struct RetryExecutor { /* private fields */ }Expand description
A retry executor that runs a fallible operation with configured retry behavior.
Implementations§
Source§impl RetryExecutor
impl RetryExecutor
Sourcepub fn new(config: RetryStrategyConfig) -> Self
pub fn new(config: RetryStrategyConfig) -> Self
Create a new retry executor with the given configuration.
Sourcepub fn from_policy(policy: RetryPolicy) -> Self
pub fn from_policy(policy: RetryPolicy) -> Self
Create a retry executor from a predefined policy.
Sourcepub fn run<T, E, F>(&self, operation: F) -> Result<T, E>
pub fn run<T, E, F>(&self, operation: F) -> Result<T, E>
Execute a fallible operation with retry behavior.
The operation receives the current attempt number (starting at 1).
Return Ok(T) on success, Err(E) on failure.
§Example
use shipper_retry::{RetryExecutor, RetryPolicy};
let executor = RetryExecutor::from_policy(RetryPolicy::Default);
let result = executor.run(|attempt| {
// Your fallible operation here
if attempt < 3 {
Err("transient error")
} else {
Ok("success")
}
});Sourcepub fn run_with_classification<T, E, F>(&self, operation: F) -> Result<T, E>
pub fn run_with_classification<T, E, F>(&self, operation: F) -> Result<T, E>
Execute a fallible operation with retry behavior and custom error classification.
The operation returns a tuple of (result, should_retry). This allows the operation to indicate whether an error is retryable.
Auto Trait Implementations§
impl Freeze for RetryExecutor
impl RefUnwindSafe for RetryExecutor
impl Send for RetryExecutor
impl Sync for RetryExecutor
impl Unpin for RetryExecutor
impl UnsafeUnpin for RetryExecutor
impl UnwindSafe for RetryExecutor
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