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 ๐ - How often each phaseโs loop looks whether it is due; each phaseโs own interval lives in
credit_registration_phase_state.
Staticsยง
- LAST_
LOGGED_ ๐SKIP - The skip reason last logged for a phase, so a paused phase or an open breaker logs once per state change instead of on every tick until it clears.
Functionsยง
- cancel_
on_ ๐termination_ signal - Kubernetes sends SIGTERM and waits
terminationGracePeriodSecondsbefore killing the pod. - clear_
skip_ ๐state - is_due ๐
- A phase is due when an admin asked for it, or when its interval has elapsed since it last began.
- log_
failure ๐ - log_
skip_ ๐if_ changed - run
- Runs the phases
processowns until SIGTERM or Ctrl-C. Each phase loops on its own, so an hour-long call in one does not hold up the others. On shutdown no phase starts another iteration, and the function returns once the iterations already running have finished. - run_
due_ ๐phase - Runs one due phase, and schedules the next run.
- run_
if_ ๐due - run_
phase_ ๐loop