Class RedbLeaderElection

Assembly: redb.Tsak.Core.Pro.dll

Leader election via the redb-backed distributed lock ().
Uses TTL-based expiry: if the leader doesn't renew within ,
another node can acquire. Epoch counter provides fencing against stale leaders.

public sealed class RedbLeaderElection : ILeaderElection

Inheritance

Object→RedbLeaderElection

Implements

Properties

CurrentEpoch

Current epoch of the leader lock.

public long CurrentEpoch { get; }

CurrentLeaderNodeId

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

public string? CurrentLeaderNodeId { get; }

IsLeader

Whether the current node is the leader.

public bool IsLeader { get; }

Methods

GetLeaderSnapshot()

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

public LeaderSnapshot GetLeaderSnapshot()

ReleaseAsync(CancellationToken)

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

public Task ReleaseAsync(CancellationToken ct = default)

RenewAsync(CancellationToken)

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

public Task<bool> RenewAsync(CancellationToken ct = default)

StepDown()

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

public void StepDown()

TryAcquireAsync(CancellationToken)

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

public Task<bool> TryAcquireAsync(CancellationToken ct = default)

Constructors