Skip to main content

Elector

Struct Elector 

Source
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

Source

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.

Source

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).

Source

pub fn role(&self) -> Role

Current self-perceived role.

Source

pub fn epoch(&self) -> u64

Current epoch.

Source

pub fn current_primary(&self) -> Option<&str>

Last-known primary id (None until first ANNOUNCE / boot declaration).

Source

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.

Source

pub fn on_message( &mut self, from_node_id: &str, msg: Message, now: Instant, ) -> Vec<Outbound>

Process one inbound message (from from_node_id) at now. Updates per-peer view, applies the state machine transitions the spec defines, returns any outbound messages the transition produced.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.