Skip to main content

StateMachine

Trait StateMachine 

Source
pub trait StateMachine<R> {
    type Error: Error + Debug + 'static;

    // Required method
    fn apply(
        &mut self,
        record: &R,
        chunk_id: ChunkId,
        global_segment: Segment,
    ) -> Result<(), Self::Error>;
}
Expand description

A trait representing a state machine of WAL that can apply records to modify its state.

The Raft-log follows a Write-Ahead Log (WAL) + State Machine pattern. This trait defines the state machine component that processes records persisted in the WAL to build and maintain application state.

§Type Parameters

  • R - The type of records that can be applied to the state machine

Required Associated Types§

Source

type Error: Error + Debug + 'static

The type of error that can occur during record application

Required Methods§

Source

fn apply( &mut self, record: &R, chunk_id: ChunkId, global_segment: Segment, ) -> Result<(), Self::Error>

Applies a record that is already persisted in the WAL to the state machine, potentially modifying its state.

§Arguments
  • record - The record to apply.
  • chunk_id - The identifier of the chunk containing this record.
  • global_segment - The global offset and size of the record in the log file.

Implementors§