How a Worker Takes a Job

How a Worker Takes a Job A workflow diagram generated by Archify. 01 / apps/mail · Redis queue 02 / Worker task 03 / One job · runs in the listener 04 / Postgres · blob storage 05 / Client-mail readers · 2 at a time each Hand off Queue Claim + run Finish Store + commit · raw email, then rows · apps/mail · Redis queue › Hand off Store + commit raw email, then rows Add job · one per email id · apps/mail · Redis queue › Hand off Add job one per email id Waiting list · oldest first · apps/mail · Redis queue › Queue Waiting list oldest first Delayed / stalled · 3 tries, then failed · apps/mail · Redis queue › Claim + run Delayed / stalled 3 tries, then failed Sweeper · jobs, gathering, client mail · Worker task › Hand off Sweeper jobs, gathering, client mail Claim + lock · lock kept renewed · Worker task › Claim + run Claim + lock lock kept renewed Complete · unlock, take next · Worker task › Finish Complete unlock, take next Load + read · row, then raw MIME · One job · runs in the listener › Claim + run Load + read row, then raw MIME Process + save · classify, anchor, read · One job · runs in the listener › Claim + run Process + save classify, anchor, read Ask for earlier mail · up to 50, then history · One job · runs in the listener › Finish Ask for earlier mail up to 50, then history email_message · rawRef · status · Postgres · blob storage › Queue email_message rawRef · status Blob storage · mail/raw/<sha>.eml · Postgres · blob storage › Claim + run Blob storage mail/raw/<sha>.eml Pipeline tables · run · step · artifact · Postgres · blob storage › Claim + run Pipeline tables run · step · artifact Client-mail queues · changes · purchase-orders · Client-mail readers · 2 at a time each › Claim + run Client-mail queues changes · purchase-orders Change reader · changes and answers · Client-mail readers · 2 at a time each › Claim + run Change reader changes and answers Purchase order reader · calls on, allow-listed · Client-mail readers · 2 at a time each › Finish Purchase order reader calls on, allow-listed email id save changes run the job client-changes purchase-orders raw MIME row by id save order hand on linked mail done names mail we lack save artifacts crash or lock expiry retry after backoff no run yet then write MIME commit rows re-add job wakes one Legend mail or worker step job state in Redis Postgres or blob