Skip to main content

Module progress

Module progress 

Source
Expand description

Heartbeat / liveness progress for long-running work.

At default verbosity anodizer shows a per-artifact result line but nothing during a step, so a legitimately slow operation — a large cargo publish, a multi-minute asset upload over a slow link, notarytool polling Apple — is visually indistinguishable from a hang. Two heartbeat paths close that gap, both emitting a still … line (heartbeat_message) on a shared cadence:

  • Subprocess waits go through crate::run, whose capture loop runs a run_ticker thread. This covers every shelled-out tool — cargo, notarytool, docker, snapcraft, …
  • Pure-async waits (the octocrab / forge HTTP calls that never spawn a subprocess) wrap their future in with_heartbeat.

Both suppress at verbose (the live subprocess tee is already the progress signal) and when the cadence env is set to 0.

Constants§

DEFAULT_HEARTBEAT_INTERVAL
Default quiet period before the first heartbeat, and the cadence between subsequent ones.
HEARTBEAT_INTERVAL_ENV
Env override for the heartbeat cadence, in milliseconds. The test hook: the suite sets a few-ms interval so a heartbeat fires without a 30s wait. 0 disables heartbeats entirely; a malformed value degrades to the default (heartbeats are presentation, never worth failing a run over).

Functions§

format_elapsed
Render d for a heartbeat line using the tool’s canonical compact duration spelling (45s, 2m15s, 1h5m) — the same HumanDuration format config values round-trip through, so a duration reads identically everywhere anodizer prints one.
heartbeat_interval
Resolve the heartbeat cadence — None when disabled (…_MS=0).
heartbeat_message
Render one heartbeat line: still {action} ({elapsed}). The single template both drivers print, so the line’s shape cannot drift between the subprocess ticker (action = running cargo (aarch64-…)) and the async combinator (action = uploading foo.tar.gz).
heartbeat_period
The active heartbeat cadence for log, or None when heartbeats are off — suppressed outside Normal verbosity (StageLogger::heartbeats_enabled) or when heartbeat_interval is disabled. The single gate both the subprocess ticker and with_heartbeat consult, so the on/off policy lives in one place rather than being re-derived per driver.
run_ticker
Run on_tick every interval until the paired Sender sends or is dropped, then return. The caller spawns this on whatever thread flavor it owns (a scoped thread in crate::run, an owned thread in crate::disk::FreeSpaceSampler); the sender-drop wake means shutdown is immediate — the ticker never has to wait out a residual interval. Because each emission is followed by a fresh full-interval wait, a scheduler stall can never burst a backlog of ticks: at most one fires per elapsed period.
with_heartbeat
Await fut, emitting a heartbeat_message every heartbeat_interval until it resolves, then return its output.