pub struct Elector { /* private fields */ }Expand description
Top-level state machine for a single kevy node in the v3-cluster Phase 1.5 election. One per process (election is per-node, not per-shard).
Implementations§
Source§impl Elector
impl Elector
Sourcepub fn new(
node_id: impl Into<String>,
peer_ids: Vec<String>,
my_advertised_addr: impl Into<String>,
start_role: Role,
config: ElectConfig,
jitter: ElectJitter,
) -> Self
pub fn new( node_id: impl Into<String>, peer_ids: Vec<String>, my_advertised_addr: impl Into<String>, start_role: Role, config: ElectConfig, jitter: ElectJitter, ) -> Self
Build an elector for a node with the given stable id, peer
membership (the full list including self), advertised
host:port, and config tunables.
start_role is Primary for the bootstrap node (operator-
declared at first start) and Replica for the rest.
Sourcepub fn set_repl_offset(&mut self, offset: u64)
pub fn set_repl_offset(&mut self, offset: u64)
Update this node’s repl_offset (called by the kevy-server
adapter when the replication source / runner advances).
Sourcepub fn current_primary(&self) -> Option<&str>
pub fn current_primary(&self) -> Option<&str>
Last-known primary id (None until first ANNOUNCE / boot
declaration).
Sourcepub fn tick(&mut self, now: Instant) -> Vec<Outbound>
pub fn tick(&mut self, now: Instant) -> Vec<Outbound>
Drive the elector forward by now. Schedules outbound HB
per peer, detects DOWN, transitions Candidate → Primary on
quorum, and runs the candidate’s election-timeout fallback.
Returns a fresh batch of outbound messages — callers should
drain in one pass.