Skip to main content

Crate pleasehold

Crate pleasehold 

Source
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 GET over a raw tokio::net::TcpStream. Healthy on 2xx/3xx, or an exact match to expect_status. No TLS in v1; an https:// target should use Probe::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.
  • shellsh -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.
BackoffConfig
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 existing wait-for gate had before backoff existed.
HttpTarget
A parsed plaintext-HTTP target. v1 supports http:// only.
PollFailure
PollSuccess

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 status acceptable? With expect = Some(n) only an exact n passes; 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 an https:// scheme and an empty host.
poll_until
Poll probe under cfg until 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-in Probe enum — 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 GET attempt against target. Ok(status) on a complete response line; Err(reason) on connect/write/read failure or a malformed status line. attempt_timeout bounds the whole connect+request+response.
probe_shell_once
One shell-condition attempt: sh -c <command>, healthy on exit 0. Err carries 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§

BoxedProbeFn
Type alias for a boxed async probe closure, kept available for callers that want to poll something Probe can’t express (e.g. a DB query) without duplicating the backoff loop. Not used by poll_until itself — see poll_until_with.