pub struct RetryMiddleware {
pub max_retries: u32,
pub retry_http_codes: Vec<u16>,
pub backoff_factor: f64,
pub max_delay: Duration,
}Expand description
Middleware that retries failed requests.
Fields§
§max_retries: u32Maximum number of times to retry a request.
retry_http_codes: Vec<u16>HTTP status codes that should trigger a retry.
backoff_factor: f64Factor for exponential backoff (delay = backoff_factor * (2^retries)).
max_delay: DurationMaximum delay between retries.
Implementations§
Source§impl RetryMiddleware
impl RetryMiddleware
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Sets the maximum number of times to retry a request.
Sourcepub fn retry_http_codes(self, retry_http_codes: Vec<u16>) -> Self
pub fn retry_http_codes(self, retry_http_codes: Vec<u16>) -> Self
Sets the HTTP status codes that should trigger a retry.
Sourcepub fn backoff_factor(self, backoff_factor: f64) -> Self
pub fn backoff_factor(self, backoff_factor: f64) -> Self
Sets the factor for exponential backoff.
Trait Implementations§
Source§impl Clone for RetryMiddleware
impl Clone for RetryMiddleware
Source§fn clone(&self) -> RetryMiddleware
fn clone(&self) -> RetryMiddleware
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 RetryMiddleware
impl Debug for RetryMiddleware
Source§impl Default for RetryMiddleware
impl Default for RetryMiddleware
Source§impl<C: Send + Sync> Middleware<C> for RetryMiddleware
impl<C: Send + Sync> Middleware<C> for RetryMiddleware
fn name(&self) -> &str
fn process_request<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client: &'life1 C,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn process_response<'life0, 'async_trait>(
&'life0 mut self,
response: Response,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Response>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
request: &'life1 Request,
error: &'life2 SpiderError,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl Freeze for RetryMiddleware
impl RefUnwindSafe for RetryMiddleware
impl Send for RetryMiddleware
impl Sync for RetryMiddleware
impl Unpin for RetryMiddleware
impl UnsafeUnpin for RetryMiddleware
impl UnwindSafe for RetryMiddleware
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