Class StoredMailRederivationHandler
- Namespace
- MailFathom.Application.Mail.Maintenance
- Assembly
- MailFathom.Application.dll
Carries one segment of a re-derivation: bounded passes over the scope's stored mail, for as long as the attempt lasts.
public sealed class StoredMailRederivationHandler : IJobHandler
- Inheritance
-
StoredMailRederivationHandler
- Implements
- Inherited Members
Remarks
The deployment walks the mailbox rather than the operator's terminal, which is the whole of what this job type exists for. An attempt runs pass after pass while its lease is renewed underneath it, and each pass commits what it re-read together with the position it reached — so an attempt stopped by the execution timeout, by a shutdown, or by a lease that moved on leaves durable work behind and nothing has to be walked twice.
What it does not do is hold a worker for as long as a mailbox takes. An attempt that is stopped with mail still ahead of it hands the rest of the walk to a segment of its own: the run's segment count moves on, and the job that carries it is enqueued under the key that count names. That is what keeps a walk of tens of thousands of messages inside the queue's own bounds instead of turning an execution timeout into a failure of ordinary work.
Running it twice with one payload is the same as running it once, which is what the queue asks of every handler. The pass writes the same reading of the same immutable bytes, and each batch commits the position it reached together with what it read into the run — so a second attempt that overlapped the first neither loses its progress nor counts it twice, and one killed between two batches leaves the run reporting exactly the mail that was really re-read.
Constructors
- StoredMailRederivationHandler(StoredMailRederivation, IStoredMailRederivationRunStore, IJobStore, OptimisticConcurrencyRetryPolicy, IStoredMailRederivationTelemetry)
Initializes the handler from the walk it drives and the record it keeps.
Properties
- JobType
Gets the job type this handler runs, which is also the contract its payload arrives under.
Methods
- RunAsync(IJobPayload, CancellationToken)
Runs the work the payload describes.