Method ClaimAsync
- Namespace
- MailFathom.Application.Coordination
- Assembly
- MailFathom.Application.dll
ClaimAsync(WorkScope, WorkLeaseHolder, TimeSpan, CancellationToken)
Takes exclusive hold of a scope nothing holds, or whose holder's lease has run out.
Task<WorkLease?> ClaimAsync(WorkScope scope, WorkLeaseHolder holder, TimeSpan leaseDuration, CancellationToken cancellationToken)
Parameters
scopeWorkScopeThe unit of work to hold.
holderWorkLeaseHolderThe hold the lease would be stamped with.
leaseDurationTimeSpanHow long the scope is held from now, unless it is renewed.
cancellationTokenCancellationTokenCancels the claim.
Returns
Remarks
An absent answer is not a failure and not something to report: the work is somebody else's for now, so a caller waits and asks again on the interval it would have run on. What holds what is a question the lease table answers about the deployment rather than one the replica that happened to ask answers about itself.
A holder that already holds the scope is refused as well, because a live lease is a live lease whoever asks. A holder extends what it has through RenewAsync(WorkScope, WorkLeaseHolder, TimeSpan, CancellationToken), which is the one operation that says so.
Exceptions
- ArgumentNullException
Thrown when
scopeorholderis null.- ArgumentOutOfRangeException
Thrown when
leaseDurationis not positive.