Table of Contents

Method RunAsync

Namespace
MailFathom.Application.Mail.Maintenance
Assembly
MailFathom.Application.dll

RunAsync(StoredMailRederivationRunId, StoredMailScope, CancellationToken)

Runs one bounded pass over the scope's stored mail, for the run that asked for it.

public Task<StoredMailRederivationPass> RunAsync(StoredMailRederivationRunId runId, StoredMailScope scope, CancellationToken cancellationToken)

Parameters

runId StoredMailRederivationRunId

The run this pass advances, which every write it makes is conditional on still being the scope's.

scope StoredMailScope

The account, and the one folder of it, whose stored mail is re-read.

cancellationToken CancellationToken

Cancels the pass between batches and between emails.

Returns

Task<StoredMailRederivationPass>

What this pass re-derived, and whether the scope still holds mail a further pass would reach.

Remarks

It asks for no permission, deliberately, and requires the process itself instead. What reaches it is a job this deployment enqueued when an operator asked for the run, so there is no caller to hold a grant, and requiring an administrative one here would mean the walk ran under a credential nobody presented. The operator's grant is asked for where the operator is — StoredMailRederivationRequests — and requiring the process identity here is what makes a caller reaching this method from an entrypoint added later a refusal rather than a mailbox-wide pass under no grant at all.

A pass whose run is over reports nothing remaining and commits nothing further. That is what an attempt whose lease was believed lost looks like from here — another attempt reached the end of the scope while this one was still reading — and there is nothing left for this pass to do, because the scope belongs to whatever run the operator asks for next rather than to this one.

Exceptions

ArgumentNullException

Thrown when scope is null.

PersistenceConcurrencyConflictException

Thrown when a competing writer wins a race that the bounded retries could not resolve. Batches already committed stay durable, and the next pass resumes from the committed position.

PrincipalNotAuthorizedException

Thrown when anything but this deployment's own process reached the use case.

OperationCanceledException

Thrown when the caller cancels. Committed batches stay durable.