Interface IEmailQueueService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service for the outbound email queue. Emails are enqueued by the application and delivered asynchronously by a background SMTP processor.
public interface IEmailQueueService
Methods
DequeueNextAsync(string, CancellationToken)
Atomically claims and dequeues the next pending email using
FOR UPDATE SKIP LOCKED. Safe for concurrent LoginServers.
Throws DatabaseEntityNotFoundException if the queue is empty.
Task<DatabaseResult<EmailQueueData>> DequeueNextAsync(string claimedBy, CancellationToken cancellationToken = default)
Parameters
claimedBystringIdentifier of the claiming server (e.g. server name).
cancellationTokenCancellationTokenCancellation token.
Returns
EnqueueAsync(string, string, string, string, CancellationToken)
Enqueues an email for asynchronous delivery.
Task<DatabaseResult> EnqueueAsync(string recipientEmail, string recipientUsername, string subject, string body, CancellationToken cancellationToken = default)
Parameters
recipientEmailstringRecipient email address.
recipientUsernamestringAssociated account username.
subjectstringEmail subject line.
bodystringEmail body (plain-text or HTML).
cancellationTokenCancellationTokenCancellation token.
Returns
HasPendingForUserAsync(string, CancellationToken)
Returns true if the specified user already has a pending (unsent, unclaimed) verification email in the queue. Prevents duplicate/spam emails.
Task<DatabaseResult<bool>> HasPendingForUserAsync(string recipientUsername, CancellationToken cancellationToken = default)
Parameters
recipientUsernamestringcancellationTokenCancellationToken
Returns
MarkFailedAsync(long, string, int, CancellationToken)
Marks an email delivery attempt as failed and increments the attempt counter.
Emails exceeding maxAttempts are left in the queue
with the error recorded so operators can investigate.
Task<DatabaseResult> MarkFailedAsync(long id, string error, int maxAttempts = 5, CancellationToken cancellationToken = default)
Parameters
idlongerrorstringmaxAttemptsintcancellationTokenCancellationToken
Returns
MarkSentAsync(long, CancellationToken)
Marks an email as successfully sent.
Task<DatabaseResult> MarkSentAsync(long id, CancellationToken cancellationToken = default)
Parameters
idlongcancellationTokenCancellationToken