Skip to main content

Module poll

Module poll 

Source
Expand description

The ONE wait/retry engine (02-04) — shared by the log tail here and by 02-05’s wait / restart --wait. Deliberately ~40 lines + tests instead of a retry framework (STACK.md rejected reqwest-middleware; 02-RESEARCH §Wait-loop pattern).

Semantics (research-locked):

  • adaptive interval: ×1.5 growth clamped to [interval, 30 s] (igw-cli’s verified pattern);
  • Network and GatewayRestarting are RETRIED (transient: the webserver answers 503 mid-restart and connections flap);
  • Auth is NEVER retried — retrying a rejected token cannot succeed; fail fast (exit 5);
  • any other error aborts;
  • deadline expiry → CoreError::Network-class timeout (exit 4, network_error slug — NO new variant; the source is None and url carries the poll’s subject). The last observation rides the dedicated observation field (09-07): Some ⇒ the gateway ANSWERED (Display leads “no terminal state”, never claims unreachability for an observed answer); None ⇒ today’s plain “gateway unreachable” wording preserved.

deadline = Duration::MAX runs until the process is killed — the documented Ctrl-C contract for logs -f (default kill, no envelope).

Structs§

PollConfig
Poll tuning. Default: 2 s interval, 30 s clamp, 120 s deadline.

Enums§

PollState
What one probe reports.

Functions§

poll
Poll probe until Done, the deadline expires, or an unretryable error fires (see module docs for the retry matrix). The FIRST probe runs immediately — no initial sleep.

Type Aliases§

Probe
One probe call: a boxed future borrowing the probe closure, so the closure can carry mutable state (the tail’s cursor and sink) across iterations without naming an unnameable future type.