Interface IQueueBoardService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
The operator's read of the two queues the shard makes players wait in, and the one write that unsticks a message.
public interface IQueueBoardService
Remarks
A read-only service spanning two unrelated tables, separate from
IEmailQueueService and IGroupFinderQueueService, for the same
reason IServerBoardService is separate from the per-tier server services.
Those exist to serve one process doing its job — claim the next email, form the next
group — and their methods are shaped for that: DequeueNextAsync takes a row and
hides it from everyone else, which is precisely what an operator looking at the queue must
not do. This exists to answer "is the queue moving", which is a different question with a
different shape, and folding it into them would hand a login server a method for
enumerating other people's email addresses.
Why the email half matters more than it looks. Account verification reaches a
player through email_queue and through nothing else. If no login server is claiming
rows, every new registration silently fails to complete: the site accepts the sign-up, the
row is written, and the mail never arrives. Nothing anywhere raises a hand — no error is
logged, because from the database's point of view nothing went wrong. The age of the
oldest unclaimed row is the only signal that distinguishes that outage from a quiet
Tuesday, which is why EmailQueuePage carries it and why it is computed in
the same read as the counts rather than derived from the page.
There is no method here that empties a queue. Not an oversight. A queue that can be
cleared from a browser is how the outage above becomes invisible: the rows that prove
registration is broken are the first thing somebody reaches for when the number looks
alarming, and deleting them destroys both the evidence and the emails those accounts are
still owed. The email half has exactly one write — RetryEmailAsync(long, CancellationToken) — and it
only ever moves a row back into the queue. The group finder half has none at all:
removing a queue row out from under the matching pump is how a character ends up in a
party that nothing will ever transfer them into, and the safe paths for that
(DeleteReturningAsync and the stale sweep) already exist on the game's own service,
where the caller can deal with the consequences.
Methods
FetchEmailQueueAsync(EmailQueueState?, string, int, int, CancellationToken)
One page of the outbound email queue, with per-state counts and the age of the oldest message nothing has picked up.
Task<DatabaseResult<EmailQueuePage>> FetchEmailQueueAsync(EmailQueueState? state, string search, int page, int pageSize, CancellationToken cancellationToken = default)
Parameters
stateEmailQueueState?Filter to one state, or null for any. See EmailQueueState.
searchstringCase-insensitive substring of the recipient address or the account name, or null for all. For the question "did this player's mail ever go out", which is the other reason somebody opens this page.
pageint1-based page number. Values below 1 are treated as 1.
pageSizeintRows per page. Clamped by the service.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
The counts and the two oldest-row timestamps are computed over the whole table and are
unaffected by state, search or the page: they are
the alarm, and an alarm that changed when the operator narrowed a filter would be
worse than none.
FetchGroupFinderQueueAsync(int?, int, int, CancellationToken)
One page of the group finder queue, with per-state counts.
Task<DatabaseResult<GroupFinderQueuePage>> FetchGroupFinderQueueAsync(int? status, int page, int pageSize, CancellationToken cancellationToken = default)
Parameters
statusint?Filter by GroupFinderQueueStatus, or null for any.
pageint1-based page number. Values below 1 are treated as 1.
pageSizeintRows per page. Clamped by the service.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Read-only, and there is no companion write. See the remarks on this interface.
FetchSmsQueueAsync(EmailQueueState?, string, int, int, CancellationToken)
One page of the outbound SMS queue, with per-state counts and the age of the oldest message nothing has picked up. The twin of FetchEmailQueueAsync(EmailQueueState?, string, int, int, CancellationToken).
Task<DatabaseResult<SmsQueuePage>> FetchSmsQueueAsync(EmailQueueState? state, string search, int page, int pageSize, CancellationToken cancellationToken = default)
Parameters
stateEmailQueueState?Filter to one state, or null for any.
searchstringAccount-name substring, or a whole phone number. Null for all.
pageint1-based page number. Values below 1 are treated as 1.
pageSizeintRows per page. Clamped by the service.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
The counts and ages are over the whole table, as the email read's are. The body is never projected: a verification text is a one-time code.
The search matches a phone number whole, never in part. The account name is a substring match as on the email board, but the number is compared after stripping spaces, dashes, dots and brackets, and only for equality. The page shows numbers masked to their last four digits; a substring search would let anyone with the page recover a masked number a digit at a time. An operator who already holds the number can still ask "did a code go to this phone".
RetryEmailAsync(long, CancellationToken)
Puts a claimed email back in the queue by releasing the claim on it.
Task<DatabaseResult<EmailRetryResult>> RetryEmailAsync(long id, CancellationToken cancellationToken = default)
Parameters
idlongThe email queue row.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<EmailRetryResult>>
What happened, including a refusal. A failure result with NotFound when no such row exists.
Remarks
This is the only thing "retry" can mean here, and it works because of a defect.
EmailQueueService.MarkFailedAsync increments attempts and records
last_error but never clears claimed_at, and DequeueNextAsync only
ever selects rows where claimed_at IS NULL. So a failed delivery is not retried
by anything, ever, despite the entity and the interface both documenting a retry limit
— the maxAttempts parameter is not read. Until that is fixed in the login
server, releasing the claim from here is the only way a failed verification email is
ever sent, and every row it leaves behind is an account that cannot finish registering.
A row merely claimed, with no error, is retryable too. A login server that died between claiming a message and reporting on it leaves exactly that, and it is stuck just as permanently and far more quietly than a failure — nothing wrote an error, because nothing got far enough to have one. Refusing to unstick it would leave the most likely form of this outage with no remedy on the page built to surface it.
What it does not do: it does not send anything — delivery is the login server's,
and the row simply becomes eligible again on that server's next pass — and it does not
reset attempts or clear last_error. Those are the evidence of what went
wrong, and an operator pressing retry a second time needs to see that the first one
came back.
Two rows are refused rather than acted on, and both come back as a successful result carrying Refusal: a message already sent, and a message still unclaimed. Retrying the first would re-send mail somebody already acted on; "retrying" the second would change nothing, because it is already in line and the thing it is waiting for is a login server. Neither is a database failure, and both are worth telling the operator precisely.
The read, the guard and the write are one statement, so a login server claiming the same row at the same moment produces one winner rather than a claim released out from under a delivery already in flight.
RetrySmsAsync(long, CancellationToken)
Puts a claimed text message back in the queue by releasing the claim on it. The twin of RetryEmailAsync(long, CancellationToken), with the same single-statement guard and the same two refusals (already sent; never claimed).
Task<DatabaseResult<SmsRetryResult>> RetrySmsAsync(long id, CancellationToken cancellationToken = default)
Parameters
idlongThe SMS queue row.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<SmsRetryResult>>
What happened, including a refusal. A failure result with NotFound when no such row exists.
Remarks
SmsQueueService.MarkFailedAsync releases the claim itself while attempts remain
and keeps it once they are spent, so a row that reads as failed is one the drain has
given up on. Releasing it grants exactly one more attempt: attempts is not reset,
so a further failure gives up again. A claimed row with no error — a drain that died
mid-send — is retryable too.