Enum EmailQueueState
Where an email queue row is in its life.
public enum EmailQueueState
Fields
Claimed = 1Claimed by a login server, which has not yet said whether it went out.
Failed = 2Claimed, and the last delivery attempt recorded an error.
Pending = 0Queued and unclaimed. Waiting for a login server to pick it up.
Sent = 3Delivered.
Remarks
There is no state column. email_queue models delivery with three nullable
columns — sent_at, claimed_at and last_error — and the state is the
combination of them. This enum is that combination named, decided in one place so the
filter, the counts and the badge in the browser cannot disagree about what "failed"
means.
The order of the tests matters and is part of the definition:
sent_atset — Sent. Delivered; nothing else about the row matters.claimed_atnull — Pending. In line, waiting for a login server to take it. This is the state the queue drains from, and the state that piles up when no login server is running.last_errorset — Failed. A login server took it and the delivery attempt errored.- otherwise — Claimed. A login server holds it and has not reported an outcome.
Pending is tested before the error so that a retried row reads as pending again:
retrying releases the claim but deliberately keeps last_error, because the text of
the failure is the only evidence of why it failed and an operator retrying a second time
needs it. Were the order reversed, a row put back in line would still read as failed.