pub fn assert_eventually_succeed<R>(
    task_name: &str,
    task: impl Fn() -> Result<R, Error>,
    attempts: u16,
    interval: Duration,
) -> Result<R, Error> {
    sleep(interval);
    for _ in 0..attempts {
        match task() {
            Ok(res) => return Ok(res),
            Err(e) => {
                debug!("retrying task that failed with error: {}", e);
                sleep(interval)
            }
        }
    }

    Err(eyre!(
        "Expected task to eventually succeeed, but failed after {} attempts: {}",
        attempts,
        task_name
    ))
}
/**
   A simplified version of retry logic used for testing.
   We do not need complicated retry logic as we need this
   only to test eventual consistency which should reach
   within a few seconds.
*/
A simplified version of retry logic used for testing.
We do not need complicated retry logic as we need this
only to test eventual consistency which should reach
within a few seconds.
A simplified version of retry logic used for testing . We do not need complicated retry logic as we need this only to test eventual consistency which should reach within a few seconds .
pub fn assert_eventually_succeed<R>(
    task_name: &str,
    task: impl Fn() -> Result<R, Error>,
    attempts: u16,
    interval: Duration,
) -> Result<R, Error> {
    sleep(interval);
    for _ in 0..attempts {
        match task() {
            Ok(res) => return Ok(res),
            Err(e) => {
                debug!("retrying task that failed with error: {}", e);
                sleep(interval)
            }
        }
    }
    Err(eyre!(
        "Expected task to eventually succeeed, but failed after {} attempts: {}",
        attempts,
        task_name
    ))
}
pub fn assert_eventually_succeed < R > ( task_name : & str , task : impl Fn ( ) -> Result < R , Error > , attempts : u16 , interval : Duration , ) -> Result < R , Error > { sleep ( interval ) ; for _ in 0 .. attempts { match task ( ) { Ok ( res ) => return Ok ( res ) , Err ( e ) => { debug ! ( " " e ) ; sleep ( interval ) } } } Err ( eyre ! ( " " attempts task_name ) ) }
A simplified version of retry logic used for testing.
A simplified version of retry logic used for testing .
task_name
&str
task
impl Fn() -> Result<R, Error>
attempts
u16
interval
Duration
task_name
&str
task
impl Fn() -> Result<R, Error>
attempts
u16
interval
Duration