Class SpamClassificationArrivals
- Namespace
- MailFathom.Application.Spam
- Assembly
- MailFathom.Application.dll
Asks for a classification of each message synchronization has just committed.
public sealed class SpamClassificationArrivals
- Inheritance
-
SpamClassificationArrivals
- Inherited Members
Remarks
This is the whole arrival trigger. It is reached once per stored message, after the transaction that stored the message and its content has committed, and it writes one row into the durable queue — where the work is leased, retried per message, and made idempotent by the queue's own model rather than by anything here.
A message stored without its content is deliberately not asked for. Classification reads the local content store and reports a message it cannot read as unclassifiable rather than fetching it, so enqueuing one would spend a lease to reach an answer that is already known — and the gate over derived work already releases such a message rather than holding it.
The two cheap questions are asked before the row is written, in the order they cost: whether this account classifies at all, and whether its scope covers the folder the message arrived in. An account with classification off therefore costs one settings read per stored message and reaches no queue, which is the same shape every other path through this feature has when it is switched off — and a user holding two mailboxes is answered twice, once for each, because the decision is the mailbox's rather than theirs.
What the queue answers is not acted on, and that is the bound the synchronization run needs. A row this call wrote, a row an earlier attempt already wrote, and a refusal because the queue holds as much of this type as the deployment accepts are all the same thing here: the message is stored, and a classification either happens or the wait a verdict is allowed releases the message to derived work without one. A refusal is visible as the queue depth standing at its configured bound, which is where backpressure is read from rather than from anything this type records.
Nothing from the message reaches the queue. The payload and the idempotency key both name the message's own stored identity, so an operator reading a stuck job can ask what was concluded about it, and neither carries a subject, an address, or anything else out of the mail.
Constructors
- SpamClassificationArrivals(IJobStore, ISpamClassificationSettingsReader)
Initializes the trigger over the queue it writes to and the settings that decide whether it does.
Methods
- ScheduleAsync(StoredEmailId, EmailOccurrenceId, MailAccountId, CancellationToken)
Asks for one committed message to be classified.