DefaultStateMachineHandler

Struct DefaultStateMachineHandler 

Source
pub struct DefaultStateMachineHandler<T>
where T: TypeConfig,
{ /* private fields */ }

Implementations§

Source§

impl<T> DefaultStateMachineHandler<T>
where T: TypeConfig,

Source

pub fn new( node_id: u32, last_applied_index: u64, max_entries_per_chunk: usize, state_machine: Arc<SMOF<T>>, snapshot_config: SnapshotConfig, snapshot_policy: SNP<T>, watch_event_tx: Option<Sender<WatchResponse>>, ) -> Self

Trait Implementations§

Source§

impl<T> Debug for DefaultStateMachineHandler<T>
where T: TypeConfig + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> StateMachineHandler<T> for DefaultStateMachineHandler<T>
where T: TypeConfig,

Source§

fn pending_range(&self) -> Option<RangeInclusive<u64>>

Get the interval to be processed

Source§

fn update_pending(&self, new_commit: u64)

Update pending commit index

Source§

fn read_from_state_machine(&self, keys: Vec<Bytes>) -> Option<Vec<ClientResult>>

TODO: decouple client related commands with RAFT internal logic

Source§

fn load_snapshot_data<'life0, 'async_trait>( &'life0 self, metadata: SnapshotMetadata, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<SnapshotChunk>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load snapshot data as a stream of chunks (ZERO-COPY)

Source§

fn last_applied(&self) -> u64

Source§

fn wait_applied<'life0, 'async_trait>( &'life0 self, target_index: u64, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Waits until the state machine has applied entries up to the target index. Returns error if timeout is reached before the target is applied. Read more
Source§

fn apply_chunk<'life0, 'async_trait>( &'life0 self, chunk: Vec<Entry>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Applies a batch of committed log entries to the state machine
Source§

fn apply_snapshot_stream_from_leader<'life0, 'life1, 'async_trait>( &'life0 self, current_term: u64, stream: Box<Streaming<SnapshotChunk>>, ack_tx: Sender<SnapshotAck>, config: &'life1 SnapshotConfig, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Receives and installs a snapshot stream pushed by the leader Used when leader proactively sends snapshot updates to followers
Source§

fn should_snapshot(&self, new_commit_data: NewCommitData) -> bool

Determines if a snapshot should be created based on new commit data
Source§

fn create_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(SnapshotMetadata, PathBuf)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously creates a state machine snapshot with the following steps: Read more
Source§

fn cleanup_snapshot<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, retain_count: u64, snapshot_dir: &'life1 Path, snapshot_dir_prefix: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Cleans up old snapshots before specified version
Source§

fn validate_purge_request<'life0, 'life1, 'async_trait>( &'life0 self, current_term: u64, leader_id: Option<u32>, req: &'life1 PurgeLogRequest, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validates if a log purge request from leader is authorized
Source§

fn handle_purge_request<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, current_term: u64, leader_id: Option<u32>, last_purged: Option<LogId>, req: &'life1 PurgeLogRequest, raft_log: &'life2 Arc<ROF<T>>, ) -> Pin<Box<dyn Future<Output = Result<PurgeLogResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Processes log purge requests (for non-leader nodes)
Source§

fn get_latest_snapshot_metadata(&self) -> Option<SnapshotMetadata>

Retrieves metadata of the latest valid snapshot
Source§

fn load_snapshot_chunk<'life0, 'life1, 'async_trait>( &'life0 self, metadata: &'life1 SnapshotMetadata, seq: u32, ) -> Pin<Box<dyn Future<Output = Result<SnapshotChunk>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads a specific chunk of snapshot data by sequence number

Auto Trait Implementations§

§

impl<T> !Freeze for DefaultStateMachineHandler<T>

§

impl<T> !RefUnwindSafe for DefaultStateMachineHandler<T>

§

impl<T> Send for DefaultStateMachineHandler<T>

§

impl<T> Sync for DefaultStateMachineHandler<T>

§

impl<T> Unpin for DefaultStateMachineHandler<T>
where <T as TypeConfig>::SNP: Unpin,

§

impl<T> UnwindSafe for DefaultStateMachineHandler<T>
where <T as TypeConfig>::SNP: UnwindSafe, <T as TypeConfig>::SM: RefUnwindSafe,

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more