Basic end-to-end leader-election example.
leader_election
collection.leader_election
collection, creating a common pool of leadership candidates. Every peer then runs the same selection algorithm: it reads the pool, ranks the entries, and elects the top candidate as leader. If a peer discovers that it now holds the top spot, it immediately assumes the coordinator duties.
Every five seconds all peers repeat the check, confirming the leader is still alive or electing a replacement when necessary.
leader_election
collection with the following schema:
leader_election
collection.
heartbeat_timestamp
for their own record.
priority
descending, higher wins (10 high, 1 low, 0 ineligible)initial_timestamp
_id
priority = 0
or deleting the document entirely.