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 new() -> RetryMiddleware
pub fn new() -> RetryMiddleware
Creates a new RetryMiddleware with default settings.
Sourcepub fn max_retries(self, max_retries: u32) -> RetryMiddleware
pub fn max_retries(self, max_retries: u32) -> RetryMiddleware
Sets the maximum number of times to retry a request.
Sourcepub fn retry_http_codes(self, retry_http_codes: Vec<u16>) -> RetryMiddleware
pub fn retry_http_codes(self, retry_http_codes: Vec<u16>) -> RetryMiddleware
Sets the HTTP status codes that should trigger a retry.
Sourcepub fn backoff_factor(self, backoff_factor: f64) -> RetryMiddleware
pub fn backoff_factor(self, backoff_factor: f64) -> RetryMiddleware
Sets the factor for exponential backoff.
Sourcepub fn max_delay(self, max_delay: Duration) -> RetryMiddleware
pub fn max_delay(self, max_delay: Duration) -> RetryMiddleware
Sets the maximum delay between retries.
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§fn default() -> RetryMiddleware
fn default() -> RetryMiddleware
Returns the “default value” for a type. Read more
Source§impl<C> Middleware<C> for RetryMiddleware
impl<C> 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
'life0: 'async_trait,
'life1: 'async_trait,
RetryMiddleware: '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
'life0: 'async_trait,
RetryMiddleware: '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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
RetryMiddleware: '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