pub struct WaitProgress { /* private fields */ }Expand description
Tracks one poll-until-ready loop: owns the clock, counts probes, and emits a throttled heartbeat line.
Construct it just before the loop, then per iteration use timed_out for
the bound and tick to count the probe and print a heartbeat when due:
ⓘ
let mut progress = WaitProgress::new("vikunja", "systemctl + healthcheck", timeout)
.with_prefix(format!("[{test_name}] "));
loop {
if ready { return Ok(()); }
if failed { bail!("..."); }
if progress.timed_out() { bail!("not ready after {}s", timeout.as_secs()); }
progress.tick();
tokio::time::sleep(interval).await;
}Implementations§
Source§impl WaitProgress
impl WaitProgress
Sourcepub fn new(
label: impl Into<String>,
method: impl Into<String>,
timeout: Duration,
) -> Self
pub fn new( label: impl Into<String>, method: impl Into<String>, timeout: Duration, ) -> Self
label is what we’re waiting for; method describes how readiness is
probed; the loop is bounded by timeout. Defaults to a two-space prefix
and a 5s heartbeat cadence — override with with_prefix /
with_heartbeat.
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
Set the line prefix so the heartbeat aligns with the surrounding output
(e.g. "[my-test] "). Defaults to two spaces.
Sourcepub fn with_heartbeat(self, every: Duration) -> Self
pub fn with_heartbeat(self, every: Duration) -> Self
Override how often a heartbeat prints. Defaults to 5s — right for the short service/port waits; long VM boot/SSH waits set this to 30s so they don’t flood the log.
Auto Trait Implementations§
impl Freeze for WaitProgress
impl RefUnwindSafe for WaitProgress
impl Send for WaitProgress
impl Sync for WaitProgress
impl Unpin for WaitProgress
impl UnsafeUnpin for WaitProgress
impl UnwindSafe for WaitProgress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more