Class FencedPublicationStore
The publication fence on any Dapr state store with ETags (and the TRANSACTIONAL capability the guarded writes use). Every change is one ETag-guarded write of a single key, the one thing all such stores make atomic.
Heartbeat fencing: publishers do not pass the fence per frame. The holder renews its lease every second or so; a superseded holder learns it from a rejected renewal and stops, so a stale owner publishes for at most one renewal interval after its successor claims. Times are this replica's UTC clock, as for WorkManager's recovery lease.
public sealed class FencedPublicationStore
- Inheritance
-
FencedPublicationStore
- Inherited Members
Constructors
FencedPublicationStore(IPublicationStateStore, FencedPublicationKeys?, TimeProvider?)
The publication fence on any Dapr state store with ETags (and the TRANSACTIONAL capability the guarded writes use). Every change is one ETag-guarded write of a single key, the one thing all such stores make atomic.
Heartbeat fencing: publishers do not pass the fence per frame. The holder renews its lease every second or so; a superseded holder learns it from a rejected renewal and stops, so a stale owner publishes for at most one renewal interval after its successor claims. Times are this replica's UTC clock, as for WorkManager's recovery lease.
public FencedPublicationStore(IPublicationStateStore state, FencedPublicationKeys? keys = null, TimeProvider? time = null)
Parameters
stateIPublicationStateStorekeysFencedPublicationKeystimeTimeProvider
Methods
ChangeAsync(string, string, string, bool, TimeSpan, CancellationToken)
A fresh next claims the fence: allowed when
expected is the current token, the fence is absent or
inactive, or its lease expired. next equal to
expected renews or revokes, for the holder only, and
never reactivates an inactive fence.
public Task<bool> ChangeAsync(string connectionId, string expected, string next, bool active, TimeSpan lease, CancellationToken cancellationToken = default)
Parameters
connectionIdstringexpectedstringnextstringactiveboolleaseTimeSpancancellationTokenCancellationToken
Returns
HoldsAsync(string, string, CancellationToken)
Whether token holds the active fence (one read).
public Task<bool> HoldsAsync(string connectionId, string token, CancellationToken cancellationToken = default)
Parameters
connectionIdstringtokenstringcancellationTokenCancellationToken
Returns
SweepAsync(Action<string, Exception>?, CancellationToken)
Removes fences that are inactive or expired and older than two leases, and drops them from the index.
public Task SweepAsync(Action<string, Exception>? onError, CancellationToken cancellationToken)
Parameters
onErrorAction<string, Exception>cancellationTokenCancellationToken