Interface ILeaderElection

Assembly: redb.Tsak.Core.Pro.dll

Distributed leader election via redb distributed locks.
Only one node in the cluster holds the leader lock at any time.
The leader is responsible for module assignment and rebalancing.

public interface ILeaderElection

Properties

CurrentEpoch

Current epoch of the leader lock.

long CurrentEpoch { get; }

CurrentLeaderNodeId

Node ID of the current leader (null if unknown).

string? CurrentLeaderNodeId { get; }

IsLeader

Whether the current node is the leader.

bool IsLeader { get; }

Methods

GetLeaderSnapshot()

Returns (IsLeader, Epoch, LeaderNodeId) as ONE consistent snapshot — use this instead of

LeaderSnapshot GetLeaderSnapshot()

ReleaseAsync(CancellationToken)

Releases the leader lock (graceful step-down): clears local leadership AND the store.

Task ReleaseAsync(CancellationToken ct = default)

RenewAsync(CancellationToken)

Renews the leader lock TTL. Returns true if renewal succeeded.

Task<bool> RenewAsync(CancellationToken ct = default)

StepDown()

Local, store-free voluntary step-down: immediately clears this node's leadership flag without

void StepDown()

TryAcquireAsync(CancellationToken)

Attempts to acquire the leader lock. Returns true if this node became leader.

Task<bool> TryAcquireAsync(CancellationToken ct = default)