Table of Contents

Class SmsQueueDrainService

Namespace
FishMMO.ControlPanel.Services
Assembly
FishMMO-ControlPanel.dll

Delivers the outbound SMS queue. The deliberate twin of EmailQueueDrainService.

public sealed class SmsQueueDrainService : BackgroundService, IHostedService, IDisposable
Inheritance
SmsQueueDrainService
Implements
Inherited Members

Remarks

Same shape, same reasons: the queue claim (FOR UPDATE SKIP LOCKED) is the coordination, a scope is opened per pass, a failed send stops the pass and doubles the delay to a minute, and the claim identity names the machine. See the email drain for why each of those is so. Configured by Sms:DrainIntervalSeconds and Sms:MaxPerPass.

A delivered verification SMS stamps verification_email_sent_at. What that column records is "a verification code has reached the player", which staff read when an account cannot verify; the database has no separate SMS stamp, and an SMS-only account would otherwise always look as if nothing had arrived. Sign-in does not read it. Notifications stamp nothing, for the same reason a password reset email stamps nothing.

Nothing here is audited: a background loop is not an operator.

Constructors

SmsQueueDrainService(IServiceScopeFactory, ISmsSender, IConfiguration, ILogger<SmsQueueDrainService>)

public SmsQueueDrainService(IServiceScopeFactory scopeFactory, ISmsSender sender, IConfiguration configuration, ILogger<SmsQueueDrainService> log)

Parameters

scopeFactory IServiceScopeFactory
sender ISmsSender
configuration IConfiguration
log ILogger<SmsQueueDrainService>

Methods

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

protected override Task ExecuteAsync(CancellationToken stoppingToken)

Parameters

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.