Skip to main content

RaftNode

Struct RaftNode 

Source
pub struct RaftNode { /* private fields */ }

Implementations§

Source§

impl RaftNode

Source

pub fn new(config: RaftConfig, now: u64) -> Self

Source

pub fn restart(&mut self, now: u64)

A process restart: the hard state and the log survive, everything else (commit index, applied state, pending outcomes) is rebuilt.

Source

pub fn id(&self) -> usize

Source

pub fn role(&self) -> RaftRole

Source

pub fn term(&self) -> u64

Source

pub fn leader(&self) -> Option<usize>

Source

pub fn hard_state(&self) -> &RaftHardState

Source

pub fn commit_index(&self) -> u64

Source

pub fn applied_index(&self) -> u64

Source

pub fn log(&self) -> &[RaftEntry]

The whole log, sentinel included.

Source

pub fn state(&self) -> &JournalState

Source

pub fn take_messages(&mut self) -> Vec<RaftEnvelope>

Messages to deliver; persist the hard state and log first.

Source

pub fn take_outcome(&mut self, id: u64) -> Option<RaftOutcome>

The outcome of a command proposed on this node, once applied here.

Source

pub fn forget(&mut self, id: u64)

Gives up waiting for a command (its caller timed out).

Source

pub fn propose(&mut self, now: u64, command: RaftCommand) -> bool

Proposes a command. Returns false when no leader is known, so the proposal went nowhere. Even on true the proposal may be lost.

Source

pub fn tick(&mut self, now: u64)

Advances timers to the local time now. A clock that jumps backward only delays them.

Source

pub fn step(&mut self, now: u64, envelope: RaftEnvelope)

Trait Implementations§

Source§

impl Clone for RaftNode

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 RaftNode

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> Same for T

Source§

type Output = T

Should always be Self
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.