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
jsonstringThe candidate document, as the JSON object the row will hold.
expectedVersionlongThe version the candidate was composed over.
cancellationTokenCancellationTokenCancels the commit.
Returns
- Task<long?>
The version the commit produced, or null when the document had already moved past
expectedVersion.
Exceptions
- ArgumentException
Thrown when
jsonis null, empty, white space, not a JSON object, or past MaximumOctets as the database would store it.- ArgumentOutOfRangeException
Thrown when
expectedVersionis 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.