Skip to main content

Message

Enum Message 

Source
pub enum Message {
    RequestVote {
        term: Term,
        last_log_index: LogIndex,
        last_log_term: Term,
    },
    RequestVoteResponse {
        term: Term,
        vote_granted: bool,
    },
    RequestPreVote {
        term: Term,
        last_log_index: LogIndex,
        last_log_term: Term,
    },
    RequestPreVoteResponse {
        term: Term,
        vote_granted: bool,
    },
    AppendEntries {
        term: Term,
        prev_log_index: LogIndex,
        prev_log_term: Term,
        entries: Vec<LogEntry>,
        leader_commit: LogIndex,
        read_round: u64,
    },
    AppendEntriesResponse {
        term: Term,
        success: bool,
        match_index: LogIndex,
        conflict_index: LogIndex,
        conflict_term: Term,
        read_round: u64,
    },
    InstallSnapshot {
        term: Term,
        last_included_index: LogIndex,
        last_included_term: Term,
        config: ClusterConfig,
        offset: u64,
        data: Vec<u8>,
        done: bool,
    },
    InstallSnapshotResponse {
        term: Term,
        match_index: LogIndex,
    },
}
Expand description

One RPC message.

The sender and recipient travel in the envelope (Event::Message::from and Action::Send::to); every variant carries the term it was created under so stale senders are detectable from the message alone.

Variants§

§

RequestVote

A candidate asks for a vote in a real election.

Fields

§term: Term

The candidate’s term.

§last_log_index: LogIndex

The candidate’s last log index.

§last_log_term: Term

The term of the candidate’s last log entry.

§

RequestVoteResponse

The voter’s answer to RequestVote.

Fields

§term: Term

The voter’s current term when it answered.

§vote_granted: bool

Whether the vote was granted.

§

RequestPreVote

A pre-candidate asks whether it would win an election for the hypothetical term term (the sender’s current term + 1), without the sender changing any persistent state.

Fields

§term: Term

The hypothetical future term.

§last_log_index: LogIndex

The pre-candidate’s last log index.

§last_log_term: Term

The term of the pre-candidate’s last log entry.

§

RequestPreVoteResponse

The voter’s answer to RequestPreVote. Granting it changed no persistent state on the voter and did not reset its timer.

Fields

§term: Term

The voter’s current term when it answered.

§vote_granted: bool

Whether the pre-vote was granted.

§

AppendEntries

The leader replicates entries (or, with no entries, heartbeats) to a follower.

Fields

§term: Term

The leader’s term.

§prev_log_index: LogIndex

The index immediately before the first entry in this batch.

§prev_log_term: Term

The term of the entry at prev_log_index.

§entries: Vec<LogEntry>

The entries to append, in index order.

§leader_commit: LogIndex

The leader’s commit index.

§read_round: u64

The leader’s current ReadIndex round token (0 means none).

§

AppendEntriesResponse

The follower’s answer to AppendEntries.

Fields

§term: Term

The follower’s current term when it answered.

§success: bool

Whether the batch was accepted.

§match_index: LogIndex

On success, the highest index the follower now holds contiguously from this leader. Zero on failure.

§conflict_index: LogIndex

On failure, the first index of the conflicting term in the follower’s log, or its last index + 1 when its log is too short. Zero when not applicable.

§conflict_term: Term

On failure, the term at conflict_index in the follower’s log, or term 0 when the log was simply too short.

§read_round: u64

The highest read round echoed by the follower (ReadIndex).

§

InstallSnapshot

One chunk of a snapshot transfer (docs/ARCHITECTURE.md section 7.4). Chunks of one snapshot identity arrive in strictly increasing offset order; done marks the final chunk.

Fields

§term: Term

The leader’s term.

§last_included_index: LogIndex

The snapshot’s last included index.

§last_included_term: Term

The term of the entry at last_included_index.

§config: ClusterConfig

The configuration in force at last_included_index.

§offset: u64

The byte offset of data within the snapshot payload.

§data: Vec<u8>

The chunk bytes.

§done: bool

Whether this is the final chunk.

§

InstallSnapshotResponse

The follower’s answer to an InstallSnapshot chunk.

Fields

§term: Term

The follower’s current term when it answered.

§match_index: LogIndex

The snapshot’s last included index once installed, or the follower’s snapshot base index while chunks are in flight.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

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
Source§

impl Eq for Message

Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Message

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.