Skip to main content

Module runtime_health

Module runtime_health 

Source
Expand description

What the background loops are actually doing, readable from a request.

The two states that stop feeds from updating — the DB-size watermark pause and a poller that has stopped ticking — were previously observable only as log lines. /stats publishes overdue and polled_last_hour, which move in BOTH states and distinguish neither, and /health returned a constant string. So every degraded-but-running instance presented as a green machine, and “my feeds stopped updating” left the operator with fly logs and nothing else.

This is deliberately process-local and lossy: a few atomics, no persistence, no history. It answers “what is the loop doing right now”, which is the question an operator has in the middle of an incident. Anything that needs to survive a restart already lives in SQLite (feeds.next_poll, feeds.consecutive_errors), and is read from there.

Everything here is a machine fact — no user counts, no DIDs, no feed URLs — so it can be published on the same terms as /stats. Note the actual constraint is tighter than that: /stats sits behind the Cloudflare origin lock, while /health is the ONE path exempt from it, and /health is where most of this surfaces.

Structs§

DbProbeGuard
Held by whichever request owns the in-flight database probe. Recording the verdict — or being dropped without one — releases the claim, so a panicking or cancelled handler cannot wedge every later probe. Owns an Arc rather than borrowing, so the probe can be moved into a spawned task and survive the request that started it. See RuntimeHealth::begin_db_probe for why that matters.
RuntimeHealth
Shared record of background-loop state. Cheap to read from a handler.

Enums§

DbProbe
The outcome of a database probe, as /health reports it.