Method DeriveAgainAsync
- Assembly
- MailFathom.Infrastructure.dll
DeriveAgainAsync(UserId, Func<GovernedUserRecord, UserEndpointAccess?>, CancellationToken)
Derives one user's endpoint switches again and stamps their row, if its stamp still does not match it.
Task<bool> DeriveAgainAsync(UserId user, Func<GovernedUserRecord, UserEndpointAccess?> derive, CancellationToken cancellationToken)
Parameters
userUserIdThe user.
deriveFunc<GovernedUserRecord, UserEndpointAccess?>Derives the switches the row is to carry from the record as the row holds it, or answers null to leave the row exactly as it stands, stamp included. It is called at most once, inside the write's transaction, and performs no I/O of its own. Nothing is changing which policies govern the record, so the ones it stands under and the ones it would stand under are the same policies.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<bool>
Whether the row was written. It is not where the deployment holds no such user, where the row's stamp matches by the time it is locked — another replica derived it first — or where
deriveanswered nothing.
Remarks
The record, the switches the row holds, and the policies governing it are read inside the write's own transaction, with the row locked and under the lock a policy write excludes record writes with. So a policy write either commits first, and the switches are derived from it, or commits second, and rewrites the row itself: the row is never left holding switches derived from a policy that has since been replaced, stamped as current. The record's version is not moved, because the record did not change.
Exceptions
- ArgumentException
Thrown when
usernames nobody.- ArgumentNullException
Thrown when
deriveis null.- UserSettingsUnwritableException
Thrown when the write did not commit.