Table of Contents

Method WriteAppendAsync

Namespace
MailFathom.Application.Synchronization.Restore
Assembly
MailFathom.Application.dll

WriteAppendAsync(IPersistenceSession, MailAccountId, MailboxRestoreAppend, CancellationToken)

Writes down that an append is about to be issued for one message.

Task<bool> WriteAppendAsync(IPersistenceSession session, MailAccountId account, MailboxRestoreAppend record, CancellationToken cancellationToken)

Parameters

session IPersistenceSession

The transaction the record commits in.

account MailAccountId

The account whose mailbox the copy goes back into.

record MailboxRestoreAppend

The record to write.

cancellationToken CancellationToken

Propagates caller cancellation.

Returns

Task<bool>

true when this caller is the one that took the message in hand.

Remarks

It commits before the command goes out, which is the whole of what stops a second copy.

It resolves from a fresh read rather than inserting unconditionally, because the caller commits it under the optimistic retry policy and that policy's contract is a write that means the same thing on a replay. A record already standing for the message answers false: either a commit whose answer was lost in fact landed, or a pass on another replica reached the message first, and in both readings an APPEND from this caller would be the second one.

Exceptions

ArgumentNullException

Thrown when record is null.