Skip to main content

Module credit_registration_phases

Module credit_registration_phases 

Source
Expand description

The thirteen credit-registration pipeline phases and the one-iteration dispatcher.

Both the worker loops and the test tick endpoint go through run_phase_once, so a phase cannot behave differently depending on who ran it.

Modulesยง

breaker
The circuit breaker the study-registry phases share within one worker process.
config_validation ๐Ÿ”’
The config-validation phase: the daily pass over every Suotar-enabled moduleโ€™s configuration.
enrolment_discovery ๐Ÿ”’
The enrolment-discovery phase: who the study registry says is on the course.
import ๐Ÿ”’
The import phase: the one call that creates something in the study registry.
ledger_snapshot ๐Ÿ”’
The ledger-snapshot phase: the dayโ€™s queue-depth snapshot for every ledger state.
link_emails ๐Ÿ”’
The link-emails phase: turning a claimed mail slot into a queued message.
linking_mail_resend
Re-running the account-linking send path for one person on one course.
product_token_refresh ๐Ÿ”’
The product-token-refresh phase: keeping the open university product access tokens current.
resolve_enrolments ๐Ÿ”’
The resolve-enrolments phase: which enrolment the attainment belongs to, and what we will send.
retention_sweep ๐Ÿ”’
The retention-sweep phase: the call logโ€™s 90-day window and the expired linking tokens.
student_notifications ๐Ÿ”’
The student-notifications phase: the only thing that queues a student mail about a credit registration.
verify ๐Ÿ”’
The verify phase: asking the study registry what became of a submission.
worker_loop
The loop both credit registration workers run.

Structsยง

OutcomeEvent ๐Ÿ”’
The audit half of applying an outcome. Both bodies are scrubbed on the way into the event row.
PhaseContext
Everything a phase iteration needs from its caller: the worker loop or the test tick endpoint.
PhaseScope
Which rows one iteration may touch. Which rows a phase iteration may touch. Empty means every row, which is what production runs; a narrowed scope lets a test drive the pipeline for its own course on a shared database.
Prepared ๐Ÿ”’
What one iteration of a SuotarBatchPhase settled before it sent anything.
ScopeSupport
Which of the scopeโ€™s dimensions a phaseโ€™s claim query can apply. Declared rather than assumed, so a phase added later cannot quietly ignore a scope and sweep the whole database.
TemplateCache ๐Ÿ”’
One template lookup per type and language per iteration rather than per mail. None means no template exists, which a mail phase reports rather than failing the batch it was found in.

Enumsยง

CreditRegistrationPhase
A pipeline phase. CreditRegistrationPhase::as_str is canonical: it is credit_registration_phase_state.phase, the tick endpointโ€™s ?phase= and the audit logโ€™s target_phase.
PhaseSkipReason
PhaseTick
What one dispatch attempt did.

Traitsยง

MailQueuePhase ๐Ÿ”’
A phase whose whole body is โ€œclaim rows, look up each oneโ€™s template, skip it if the template is missing, otherwise queue a mailโ€. link-emails and student-notifications are its only two shapes; run_mail_queue_phase is the loop they share.
SuotarBatchPhase ๐Ÿ”’
A phase whose iteration is โ€œclaim rows, decide in one transaction what may be asked, send one batch, write one answer per rowโ€. import, resolve-enrolments, and each of verifyโ€™s two flows; run_suotar_batch_phase is the loop they share, and the only place the transaction shape, the moved-on skipping and the counters are written down.

Functionsยง

apply_outcome ๐Ÿ”’
Applies one decided outcome to one row, with the exchange that produced it.
apply_request_level_outcome ๐Ÿ”’
Applies one request-level outcome to one row of a batch the study registry rejected whole. Returns whether the row ended up carrying an error code.
count_applied ๐Ÿ”’
Counts one written row, or skips one that had already moved on. Skipped rather than propagated: the row belongs to whoever moved it, and aborting would leave the rest of the batch in the state the preflight wrote, which no phase claims again.
counts_as_failed ๐Ÿ”’
Whether an outcome counts against the iterationโ€™s items_failed: an error code is a failed item, so a verify poll answered notRegistered is not one.
every_item_failed_transiently ๐Ÿ”’
Whether the whole batch came back saying โ€œnot nowโ€, so the worker stops burning calls. A batch with one good item is a success: something moved.
listed_person_addresses ๐Ÿ”’
Every address the study registry holds for a listed person, in the order it lists them; which one they read is not something we can know.
outcome_transition ๐Ÿ”’
The ledger write one decided outcome asks for, without the audit half apply_outcome adds. For the paths that decide an outcome without an exchange to record.
requests_json ๐Ÿ”’
The request bodies as sent, kept alongside the typed items so a rejected batch can pair each row with what was actually asked of it for the audit log.
response_item_json ๐Ÿ”’
The response item for one request item, read from the raw body rather than rebuilt from the typed value, so the audit trail holds what actually arrived.
row_facts ๐Ÿ”’
The scheduling history one outcome decision needs from a row.
row_moved_on ๐Ÿ”’
Whether the error is transition refusing to write because another writer moved the row since the snapshot the decision was made from.
run_legacy_mirror ๐Ÿ”’
run_mail_queue_phase ๐Ÿ”’
Claims, resolves templates for, and queues mail for one iteration of a MailQueuePhase. A mail with no template is skipped rather than failing the iteration: the batch is one transaction, so an error would roll back every mail that could be queued, and the claimed rows stay claimable.
run_materialize ๐Ÿ”’
Both statements that create ledger rows, bounded apart from each other. Together in one phase so the Workers tabโ€™s row-creation counter accounts for every row the pipeline invented.
run_phase_once
Runs exactly one iteration of one phase. The match below is the only place a phase implementation is registered; it is exhaustive over CreditRegistrationPhase, so a variant added there without a dispatch arm here fails to compile.
run_preconditions ๐Ÿ”’
Database-only, so it keeps running while the study registry is unreachable.
run_suotar_batch_phase ๐Ÿ”’
Runs one iteration of a SuotarBatchPhase.
suotar_error_variant ๐Ÿ”’
A failure that never reached the study registry is safe to send again; everything else may have been acted on. Anything that is not a client error was raised before the request was built.
template_language ๐Ÿ”’
Templates are stored per language and courses carry a locale. The courseโ€™s language, not the recipientโ€™s: the linking mailโ€™s recipient may have no account here, and an account records no UI language to prefer.
worker_name ๐Ÿ”’
The audit logโ€™s worker_name, which the database caps at 64 characters.