fn handle(&mut self, attempt: usize, e: reqwest::Error) -> RetryPolicy<reqwest::Error> {
        if attempt > self.max_retries {
            return RetryPolicy::ForwardError(e);
        }
        if e.is_timeout() {
            RetryPolicy::WaitRetry(Duration::from_secs(5))
        } else if let Some(status) = e.status() {
            if status.is_client_error() {
                // do not retry 4xx
                RetryPolicy::ForwardError(e)
            } else if status.is_server_error() {
                // Retry 5xx every 5 seconds
                RetryPolicy::WaitRetry(Duration::from_secs(5))
            } else {
                // Otherwise just retry every second
                RetryPolicy::WaitRetry(Duration::from_secs(1))
            }
        } else {
            // Retry other errors slightly more frequently since they may be
            // related to the engine not having started yet
            RetryPolicy::WaitRetry(Duration::from_secs(1))
        }
    }
/// Handler of errors for the retry logic
Handler of errors for the retry logic
Handler of errors for the retry logic
fn handle(&mut self, attempt: usize, e: reqwest::Error) -> RetryPolicy<reqwest::Error> {
        if attempt > self.max_retries {
            return RetryPolicy::ForwardError(e);
        }
        if e.is_timeout() {
            RetryPolicy::WaitRetry(Duration::from_secs(5))
        } else if let Some(status) = e.status() {
            if status.is_client_error() {
                // do not retry 4xx
                RetryPolicy::ForwardError(e)
            } else if status.is_server_error() {
                // Retry 5xx every 5 seconds
                RetryPolicy::WaitRetry(Duration::from_secs(5))
            } else {
                // Otherwise just retry every second
                RetryPolicy::WaitRetry(Duration::from_secs(1))
            }
        } else {
            // Retry other errors slightly more frequently since they may be
            // related to the engine not having started yet
            RetryPolicy::WaitRetry(Duration::from_secs(1))
        }
    }
fn handle ( & mut self , attempt : usize , e : reqwest :: Error ) -> RetryPolicy < reqwest :: Error > { if attempt > self . max_retries { return RetryPolicy :: ForwardError ( e ) ; } if e . is_timeout ( ) { RetryPolicy :: WaitRetry ( Duration :: from_secs ( 5 ) ) } else if let Some ( status ) = e . status ( ) { if status . is_client_error ( ) { // do not retry 4xx RetryPolicy :: ForwardError ( e ) } else if status . is_server_error ( ) { // Retry 5xx every 5 seconds RetryPolicy :: WaitRetry ( Duration :: from_secs ( 5 ) ) } else { // Otherwise just retry every second RetryPolicy :: WaitRetry ( Duration :: from_secs ( 1 ) ) } } else { // Retry other errors slightly more frequently since they may be // related to the engine not having started yet RetryPolicy :: WaitRetry ( Duration :: from_secs ( 1 ) ) } }
Handler of errors for the retry logic
Handler of errors for the retry logic
&mut self
attempt
usize
e
reqwest::Error
&mut self
attempt
usize
e
reqwest::Error