[][src]Trait raft4rs::state_machine::StateMachine

pub trait StateMachine {
    fn execute(&self, command: &[u8]) -> RaftResult<Vec<u8>>;
fn apply_log(&self, term: u64, index: u64, command: &[u8]) -> RaftResult<()>;
#[must_use] fn apply_member_change<'life0, 'async_trait>(
        &'life0 self,
        term: u64,
        index: u64,
        node_id: u64,
        action: u8,
        exists: bool
    ) -> Pin<Box<dyn Future<Output = RaftResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn apply_leader_change<'life0, 'async_trait>(
        &'life0 self,
        term: u64,
        index: u64,
        leader: u64
    ) -> Pin<Box<dyn Future<Output = RaftResult<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; }

Required methods

fn execute(&self, command: &[u8]) -> RaftResult<Vec<u8>>

this is a call execute method for leader, and no change log, example search method only run leader, now you can call it in replica , it forward to leader and return result .

fn apply_log(&self, term: u64, index: u64, command: &[u8]) -> RaftResult<()>

#[must_use]fn apply_member_change<'life0, 'async_trait>(
    &'life0 self,
    term: u64,
    index: u64,
    node_id: u64,
    action: u8,
    exists: bool
) -> Pin<Box<dyn Future<Output = RaftResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

#[must_use]fn apply_leader_change<'life0, 'async_trait>(
    &'life0 self,
    term: u64,
    index: u64,
    leader: u64
) -> Pin<Box<dyn Future<Output = RaftResult<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Loading content...

Implementors

Loading content...