Skip to main content

Module heartbeat

Module heartbeat 

Source
Expand description

The heartbeat to srv: every few seconds this process says it is alive, how old its oldest unanswered call is, and how far behind its async runtime runs. srv’s self-heal (backend::mcp_health, #2614) restarts the server when the beats stop, or the runtime has stopped turning, or a call has outlived every deadline.

It runs on a thread of its own, with a runtime of its own: a process whose main runtime is starved or stuck still beats, and says so, instead of going quiet in a way no one can tell from a closed pane.

Constants§

EVERY 🔒
FIRST 🔒
LATE_AFTER 🔒
A beat this long after the last one means the machine slept (or this thread was starved): the clocks the lag and the ages are made from jumped, so that beat doesn’t speak to either.

Functions§

beat_body 🔒
The beat’s body. After a sleep (late) the runtime lag and the age of the oldest call are left out for this one beat: the tick task hasn’t had a chance to run yet, and srv would take the gap for a stuck runtime.
is_late 🔒
Whether this beat came late, by either clock: Instant stops while a machine is suspended on Linux and macOS, the wall clock doesn’t.
start 🔒
Start the beats. Does nothing without the agent’s token and slug (a process started outside AgentMux’s own spawn, a test).