Expand description
Protocol-pluggable “poll until healthy” primitive, with backoff.
Split out of yah-qed (where it backed StepKind::WaitFor, R513-F3 /
W207 Gap #5) so it can be depended on without pulling in qed’s scheduler
stack (task-runs, velveteen, …) — a caller that only wants “wait for
this thing to materialize” (a network endpoint, an npm publish landing, a
DB row appearing) should not need a CI-pipeline engine to get it.
Three dependency-free probes (no HTTP client / TLS stack — that matters for qed’s musl-static build):
- http — plaintext HTTP/1.1
GETover a rawtokio::net::TcpStream. Healthy on 2xx/3xx, or an exact match toexpect_status. No TLS in v1; anhttps://target should useProbe::Shell(e.g.curl -fsS ...) instead of pulling a TLS stack into every caller. - tcp — bare connect to
host:port. Healthy the moment it accepts. - shell —
sh -c <command>. Healthy on exit 0. The escape hatch for anything the other two can’t express (HTTPS, a CLI query, a DB check).
poll_until owns the deadline/backoff scheduling and attempt callback;
callers only supply a Probe and a BackoffConfig.
Structs§
- Attempt
- One attempt’s outcome, handed to the caller’s progress callback so it can stream “waiting… (attempt N)” without owning any of the timing logic.
- Backoff
Config - Poll timing: how long to keep trying, and how the delay between attempts
grows.
multiplier = 1.0(the default) is a plain fixed interval — the behavior every existingwait-forgate had before backoff existed. - Http
Target - A parsed plaintext-HTTP target. v1 supports
http://only. - Poll
Failure - Poll
Success
Enums§
- Probe
- A single thing to poll. Owns enough state to both label itself (for progress/failure messages) and run one attempt.
Functions§
- http_
status_ ok - Is
statusacceptable? Withexpect = Some(n)only an exactnpasses; otherwise any 2xx/3xx. - parse_
http_ url - Split a plaintext-HTTP URL into
host/port/path. Deliberately minimal — no query/fragment/userinfo handling beyond what a health-gate URL needs. Rejects anhttps://scheme and an empty host. - poll_
until - Poll
probeundercfguntil it’s healthy or the timeout elapses. - poll_
until_ with - Same loop as
poll_until, but over an arbitrary probe closure instead of the built-inProbeenum — the escape hatch for a caller whose condition is neither http/tcp/shell (e.g. an in-process DB query) and who doesn’t want to shell out just to reuse the timing logic. - probe_
http_ once - One HTTP
GETattempt againsttarget.Ok(status)on a complete response line;Err(reason)on connect/write/read failure or a malformed status line.attempt_timeoutbounds the whole connect+request+response. - probe_
shell_ once - One shell-condition attempt:
sh -c <command>, healthy on exit 0.Errcarries the trimmed tail of combined stdout+stderr so a caller can show why the condition still doesn’t hold. - probe_
tcp_ once - One TCP connect attempt against
addr(host:port).Ok(())the moment the port accepts;Err(reason)on connect failure or timeout. No bytes are exchanged — a successful connect is the whole signal.
Type Aliases§
- Boxed
Probe Fn - Type alias for a boxed async probe closure, kept available for callers
that want to poll something
Probecan’t express (e.g. a DB query) without duplicating the backoff loop. Not used bypoll_untilitself — seepoll_until_with.