Skip to content
Leader docs0.5

Single, group, and strategic contracts

Latest stable Based on Leader release 0.5.0

Understand what each model guarantees—and what work partitioning remains outside the library.

Start with the detailed LeaderElector lock-and-lease walkthrough, then use the LeaderGroupElector companion to focus on the 1 → N slot-capacity delta. Both simulations use the release-pinned Redis/Lettuce model.

LeaderElector lock and lease visual companion

LeaderGroupElector slot capacity visual companion

One lock name permits at most one compliant owner. The action is still at-least-once from a business perspective when leases expire or callers retry, so external effects need idempotency.

A group exposes up to maxLeaders independent slots and reports activeCount, availableSlots, and isFull. Slot ownership limits concurrency but does not assign unique work. Group event projections may omit the concrete leaders because revoke events do not always identify a slot.

Strategic election separates candidate registration from winner selection. Built-ins include FIFO, seeded random, and scored selection with idle-time, success-rate, recent-success, and weighted scorers. It optimizes placement; it does not by itself provide a distributed lock for arbitrary shared writes.