Skip to main content

Module supervision

Module supervision 

Source
Expand description

Supervised background loops.

A plain tokio::spawned loop that panics dies silently — the scheduler, reflector, or heartbeat simply stops until the process restarts, with nothing but one log line at panic time. Loops spawned through spawn_supervised instead restart with capped exponential backoff, and every restart is counted in a process-wide registry that insights surfaces — “scheduler restarted 14× today” becomes visible instead of a mystery.

Functions§

restart_counts
Snapshot of (task_name, restart_count) sorted by name. Empty when no supervised task has ever panicked.
spawn_supervised
Spawn a background loop that survives its own panics. make builds a fresh instance of the loop future; on panic the task is rebuilt and restarted after a capped exponential backoff. A future that returns normally ends the supervision (loops that finish on purpose stay finished).