Table of Contents

Namespace Excalibur.Dispatch.LeaderElection.Fencing

Classes

FencingTokenExhaustedException

Thrown by IssueTokenAsync(string, CancellationToken) when its domain cannot generate another strictly positive monotonic token.

FencingTokenMiddleware

Middleware that validates fencing tokens on incoming messages to prevent stale leader operations in leader election scenarios.

FencingTokenMinting

Mints a fencing token for a leadership tenure, retrying only the failures that retrying can fix.

MonotonicFencedResourceGuard

A thread-safe, in-memory IFencedResource that enforces the Chubby/Lamport sequencer rule. A fencing token identifies a leadership tenure, not an individual operation, so an operation is accepted when its token is greater than or equal to the highest token previously accepted (a non-decreasing sequence), and the high-water mark advances atomically. Only a strictly lower token — presented by a superseded leader — is rejected. This admits the same leader presenting its stable per-tenure token across multiple operations, while still fencing out a stale predecessor.

StaleFencingTokenException

Thrown by GuardAsync(long, CancellationToken) when the presented fencing token is below the highest token the resource has already observed — the Chubby/Lamport sequencer rule that rejects operations from a superseded leader. A token equal to that high-water mark is the incumbent leader re-presenting its pinned per-tenure token, so it is accepted and this exception is not thrown.

Interfaces

IFencedResource

A resource protected by the fencing-token pattern: it records the highest fencing token it has observed and rejects any operation whose token is below that high-water mark. A token at or above the mark is accepted, and the mark never moves backward.

IFencingTokenIssuer

Advances authoritative fencing marks, in addition to observing and validating them.

IFencingTokenProvider

Provides fencing tokens for leader election scenarios to prevent stale leader operations.