[][src]Trait lol_core::RaftApp

pub trait RaftApp: Sync + Send + 'static {
    type Snapshot: ToSnapshotStream + FromSnapshotStream;
#[must_use]    fn process_message<'life0, 'async_trait>(
        &'life0 self,
        request: Message
    ) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn apply_message<'life0, 'async_trait>(
        &'life0 self,
        request: Message,
        apply_index: Index
    ) -> Pin<Box<dyn Future<Output = Result<(Message, Option<Self::Snapshot>)>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn install_snapshot<'life0, 'life1, 'async_trait>(
        &'life0 self,
        snapshot: Option<&'life1 Self::Snapshot>,
        apply_index: Index
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn fold_snapshot<'life0, 'life1, 'async_trait>(
        &'life0 self,
        old_snapshot: Option<&'life1 Self::Snapshot>,
        requests: Vec<Message>
    ) -> Pin<Box<dyn Future<Output = Result<Self::Snapshot>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

the abstraction for user-defined application runs on the RaftCore.

Associated Types

Loading content...

Required methods

#[must_use]fn process_message<'life0, 'async_trait>(
    &'life0 self,
    request: Message
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

how state machine interacts with inputs from clients.

#[must_use]fn apply_message<'life0, 'async_trait>(
    &'life0 self,
    request: Message,
    apply_index: Index
) -> Pin<Box<dyn Future<Output = Result<(Message, Option<Self::Snapshot>)>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

almost same as process_message but is called in log application path. this function may return new "copy snapshot" as a copy of the state after application.

#[must_use]fn install_snapshot<'life0, 'life1, 'async_trait>(
    &'life0 self,
    snapshot: Option<&'life1 Self::Snapshot>,
    apply_index: Index
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

special type of apply_message but when the entry is snapshot entry. snapshot is None happens iff apply_index is 1 which is the most initial snapshot.

#[must_use]fn fold_snapshot<'life0, 'life1, 'async_trait>(
    &'life0 self,
    old_snapshot: Option<&'life1 Self::Snapshot>,
    requests: Vec<Message>
) -> Pin<Box<dyn Future<Output = Result<Self::Snapshot>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

this function is called from compaction threads. it should return new snapshot from accumulative compution with the old_snapshot and the subsequent log entries.

Loading content...

Implementors

Loading content...