Skip to main content

Module periodic_worker

Module periodic_worker 

Source
Expand description

The tick-interval scaffold shared by every background worker that polls the database on a fixed period: regrader, chatbot_syncer and the credit registration phase runners.

Structs§

PeriodicWorkerConfig
How a worker’s ticking loop should behave, so the loop itself carries none of that per-worker detail.

Functions§

is_db_disconnect
True when an error’s source is a sqlx::Error::Io, which is usually the database being reset underneath a local development cluster: the caller’s cue to log its own hint and, if it keeps a connection open across ticks, reacquire one. Takes the source directly (error.source()) rather than the error, since anyhow::Error does not implement std::error::Error.
run_periodic_worker
Runs body on config.tick_interval forever, logging config.still_running_message every config.still_running_every ticks. A body that returns Err stops the loop and becomes this function’s return value, the same as an unhandled error used to exit the worker’s main.