Coordinator
View SourceThe Coordinator maintains cluster state through Raft distributed consensus and orchestrates Director lifecycle during leadership changes. It serves as the authoritative source for cluster configuration and service directory information, enabling distributed coordination across all nodes.
Location: lib/bedrock/control_plane/coordinator.ex
Consensus Leadership
Coordinators use Raft consensus to maintain cluster configuration and service directories. The leader Coordinator persists changes through consensus, ensuring consistent state replication across all coordinator nodes and automatic failover during leader elections.
Leader readiness states prevent race conditions: :leader_waiting_consensus delays Director startup until service directory population completes, then transitions to :leader_ready for normal operations.
Service Directory Authority
Link nodes register services with the leader Coordinator through register_link/4 or register_services/2 operations. Service mappings replicate across all coordinators through consensus, providing Directors with complete topology information during recovery.
Director Lifecycle Management
Coordinator creates Directors with unique, monotonically increasing epoch numbers during leadership changes. This prevents split-brain scenarios while ensuring Directors receive populated service directories before starting recovery orchestration.
Complete Flow: For cluster initialization and service registration sequences, see Cluster Startup Deep Dive.