Skip to main content

Module worker_loop

Module worker_loop 

Source
Expand description

The loop both credit registration workers run.

The processes differ only in which phases they own and how often they look, so the scheduling lives here instead of in each of them.

Constantsยง

STILL_RUNNING_MESSAGE_TICKS ๐Ÿ”’
Ten minutes of ticks. The per-phase heartbeat in the database is the machine-readable half.
TICK_INTERVAL_SECS ๐Ÿ”’
How often the loop looks for a due phase; each phaseโ€™s own interval lives in credit_registration_phase_state.

Functionsยง

is_due ๐Ÿ”’
A phase is due when an admin asked for it, or when its interval has elapsed since it last began.
log_failure ๐Ÿ”’
phase_states ๐Ÿ”’
Every phaseโ€™s state in one read, so a tick costs one query rather than one per owned phase.
run
Runs the phases this process owns until it is stopped, matching process_name against CreditRegistrationPhase::process_name.
run_due_phase ๐Ÿ”’
Runs one due phase, and schedules the next run.