Interface ISingletonWork
- Namespace
- Stratara.Abstractions.Singleton
- Assembly
- Stratara.Abstractions.dll
A unit of work that runs once per cluster, on a period: an outbox drain, a flush, a recovery sweep. The host registers an implementation and the execution model runs it in one place in the cluster, identified by Name, so no two hosts run it at the same time and no lock is needed to make that so. Two runs of the same work never overlap.
public interface ISingletonWork
- Extension Methods
Properties
Name
The name that identifies the work across the cluster.
string Name { get; }
Property Value
Period
How often the work runs. A run that takes longer than the period delays the next one; it is never doubled.
TimeSpan Period { get; }
Property Value
Methods
RunAsync(CancellationToken)
Runs the work once. Resolved from a fresh scope for every run, so it may take scoped dependencies.
Task RunAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancelled when the host running the work shuts down.
Returns
- Task
A task that completes when the run has ended.