Skip to main content

eventually_within

Function eventually_within 

Source
pub fn eventually_within<T>(
    timeout: Duration,
    check: impl FnMut() -> Option<T>,
) -> T
Expand description

eventually with another deadline: retries check every 100 ms for up to timeout.

For effects slower than 30 seconds (a pipeline of several jobs), or to fail fast on a quick one.

§Panics

When check still returns None after timeout.

§Examples

use std::time::Duration;

let value = ocre::testing::eventually_within(Duration::from_secs(120), || Some(42));
assert_eq!(value, 42);