Skip to main content

Module leader_lease

Module leader_lease 

Source
Expand description

CAS-backed leader lease with TTL and a monotonic fencing token. One object per sequence at control/leader-lease/v{seq:016}.json, written with PutMode::Create so the CAS works on every backend (LocalFileSystem included). The lease prevents split-brain: a stale leader whose lease has expired loses the CAS to whoever acquires next, and the fencing token advances only on an owner change so followers can reject writes carrying a stale token.

Structs§

LeaderLease
A durable leader lease record.
LeaderLeaseConfig
Tunables for the lease renewal loop.
LeaderLeaseManager
Periodically renews the leader lease and publishes the latest record on a watch channel so other tasks can gate on the fencing token.
LeaderLeaseStore
I/O wrapper for LeaderLease on an object store.

Enums§

LeaseError
Errors loading or saving a LeaderLease.
LeaseOutcome
Result of a LeaderLeaseStore::try_acquire attempt.

Functions§

lease_grants_leadership
True iff lease is held by me and not expired at now_ms.