Interface IWorkLeaseRunner
- Namespace
- MailFathom.Application.Coordination
- Assembly
- MailFathom.Application.dll
Runs one piece of work while this replica holds the lease on its scope, and runs nothing while another does.
public interface IWorkLeaseRunner
Remarks
The seam application work takes a lease through, because taking one is more than a claim: the lease has to be renewed while the work runs, each statement against the store needs a scope of its own so it never shares a persistence session with the work it guards, and the lease has to be given back once the work ends. All three are the host's, so the work is handed in rather than the lease handed out, and a caller cannot forget the release.
What a caller is promised is WorkLease's: one writer, never one runner. The token the work receives is cancelled on the first renewal that does not complete, strictly before the lease could expire and another replica take the scope, so work that observes it between steps commits nothing as a second writer.
Methods
- TryRunUnderLeaseAsync(WorkScope, Func<CancellationToken, Task>, CancellationToken)
Takes the lease on a scope, runs the work under it, and gives the lease back once the work ends.