[][src]Function kwait::exponential_backoff

pub fn exponential_backoff<F>(
    backoff: &mut Backoff,
    condition: F
) -> Result<(), Box<dyn Error>> where
    F: Fn() -> Result<bool, Box<dyn Error>> + Copy

exponential_backoff repeats a condition check with exponential backoff.

It repeatedly checks the condition and then sleeps, using backoff.step() to determine the length of the sleep and adjust Duration and steps. Stops and returns as soon as:

  1. the condition check returns true or an error,
  2. backoff.steps checks of the condition have been done, or
  3. a sleep truncated by the cap on duration has been completed. In case (1) the returned error is what the condition function returned. In all other cases, WaitTimeoutError is returned.