Table of Contents

Method CommitAsync

Namespace
MailFathom.Infrastructure.Persistence.Settings
Assembly
MailFathom.Infrastructure.dll

CommitAsync(string, long, CancellationToken)

Replaces the persisted configuration document, if it still stands at the expected version.

Task<long?> CommitAsync(string json, long expectedVersion, CancellationToken cancellationToken)

Parameters

json string

The candidate document, as the JSON object the row will hold.

expectedVersion long

The version the candidate was composed over.

cancellationToken CancellationToken

Cancels the commit.

Returns

Task<long?>

The version the commit produced, or null when the document had already moved past expectedVersion.

Exceptions

ArgumentException

Thrown when json is null, empty, white space, not a JSON object, or past MaximumOctets as the database would store it.

ArgumentOutOfRangeException

Thrown when expectedVersion is negative.

RootSettingsUnwritableException

Thrown when the statement did not commit. Every failure but two leaves the persisted document exactly as it was; the exceptions are a command timeout and a connection lost while the statement was in flight, because the statement had been sent by then, so whether it applied is settled by reading the version now in force rather than assumed here.