async fn start_poll_upstream_retry(
    backend: &Backend,
    key: &ImageKey,
    retry: usize,
) -> Result<UpstreamResponse, Box<dyn std::error::Error>> {
    let mut count = 0;
    loop {
        let res = start_poll_upstream(backend, key).await;

        // end the function with the result value if the result is good OR
        // the counter exceeds retry
        count += 1;
        if res.is_ok() || count >= retry {
            return res;
        }

        // log if an error occurs (as a warning, because it will be retried)
        if let Err(ref e) = res {
            log::warn!("failure during upstream poll (will retry): {}", e);
        }

        // we got here because the request failed, so lets wait a bit...
        tokio::time::sleep(Duration::from_millis(100)).await;
    }
}
/// Will attempt to retry `start_poll_upstream` until a successful result is returned
/// or the total requests meets/exceeds the `retry` parameter.
Will attempt to retry `start_poll_upstream` until a successful result is returned
or the total requests meets/exceeds the `retry` parameter.
Will attempt to retry ` start_poll_upstream ` until a successful result is returned or the total requests meets / exceeds the ` retry ` parameter .
async fn start_poll_upstream_retry(
    backend: &Backend,
    key: &ImageKey,
    retry: usize,
) -> Result<UpstreamResponse, Box<dyn std::error::Error>> {
    let mut count = 0;
    loop {
        let res = start_poll_upstream(backend, key).await;
        // end the function with the result value if the result is good OR
        // the counter exceeds retry
        count += 1;
        if res.is_ok() || count >= retry {
            return res;
        }
        // log if an error occurs (as a warning, because it will be retried)
        if let Err(ref e) = res {
            log::warn!("failure during upstream poll (will retry): {}", e);
        }
        // we got here because the request failed, so lets wait a bit...
        tokio::time::sleep(Duration::from_millis(100)).await;
    }
}
async fn start_poll_upstream_retry ( backend : & Backend , key : & ImageKey , retry : usize , ) -> Result < UpstreamResponse , Box < dyn std :: error :: Error > > { let mut count = 0 ; loop { let res = start_poll_upstream ( backend , key ) . await ; // end the function with the result value if the result is good OR // the counter exceeds retry count += 1 ; if res . is_ok ( ) || count >= retry { return res ; } // log if an error occurs (as a warning, because it will be retried) if let Err ( ref e ) = res { log :: warn ! ( " " e ) ; } // we got here because the request failed, so lets wait a bit... tokio :: time :: sleep ( Duration :: from_millis ( 100 ) ) . await ; } }
Will attempt to retry `start_poll_upstream` until a successful result is returned
or the total requests meets/exceeds the `retry` parameter.
Will attempt to retry ` start_poll_upstream ` until a successful result is returned or the total requests meets / exceeds the ` retry ` parameter .
backend
&Backend
key
&ImageKey
retry
usize