Skip to main content

Message

Enum Message 

Source
pub enum Message {
    Hb {
        epoch: u64,
        node_id: String,
        role: Role,
        repl_offset: u64,
    },
    Offer {
        new_epoch: u64,
        candidate_id: String,
        repl_offset: u64,
    },
    Accept {
        epoch: u64,
        accepter_id: String,
    },
    Announce {
        epoch: u64,
        new_primary_id: String,
        new_primary_addr: String,
    },
}
Expand description

One decoded message off the control wire. The four variants mirror the four verbs in the protocol spec.

Variants§

§

Hb

HB <epoch> <node_id> <role> <repl_offset> — heartbeat. Sent every hb_interval_ms (default 200 ms) by every node to every other peer. Receiver updates its per-peer last-seen + cached view; there is no ACK.

Fields

§epoch: u64

Election epoch the sender believes is current.

§node_id: String

Sender’s node id (operator-declared, stable, unique).

§role: Role

Sender’s self-perceived role.

§repl_offset: u64

Highest applied replication offset on the sender.

§

Offer

OFFER <new_epoch> <candidate_id> <repl_offset> — a replica that flagged the primary DOWN AND won candidate- selection (highest offset → lowest node-id) broadcasts this to ask for quorum ACCEPT.

Fields

§new_epoch: u64

Strictly greater than every previously-seen epoch.

§candidate_id: String

Candidate’s node id.

§repl_offset: u64

Candidate’s repl_offset — peers reject the OFFER if they themselves have a higher offset (a better candidate must exist).

§

Accept

ACCEPT <epoch> <accepter_id> — a peer’s vote for an OFFER. Each peer casts at most ONE accept per epoch (prevents two candidates from gathering quorum in the same round).

Fields

§epoch: u64

The epoch being voted for.

§accepter_id: String

The voter’s node id.

§

Announce

ANNOUNCE <epoch> <new_primary_id> <new_primary_addr> — the winning candidate broadcasts this on hitting quorum N/2 + 1 ACCEPTs. Peers update their current_epoch and current_primary, then retarget kevy-replicate at the new primary. The old primary (if alive) sees this with a newer epoch and demotes.

Fields

§epoch: u64

The new election epoch.

§new_primary_id: String

New primary’s node id.

§new_primary_addr: String

New primary’s host:port (the kevy compat port, where the v1.18 REPLICAOF handshake connects).

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.