Trait openraft::storage::RaftSnapshotBuilder
source · pub trait RaftSnapshotBuilder<C, SD>: Send + Sync + 'staticwhere
C: RaftTypeConfig,
SD: AsyncRead + AsyncWrite + AsyncSeek + Send + Sync + Unpin + 'static,{
// Required method
fn build_snapshot<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Snapshot<C::NodeId, C::Node, SD>, StorageError<C::NodeId>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
A trait defining the interface for a Raft state machine snapshot subsystem.
This interface is accessed read-only from snapshot building task.
Typically, the snapshot implementation as such will be hidden behind a reference type like
Arc<T>
or Box<T>
and this interface implemented on the reference type. It can be
co-implemented with RaftStorage
interface on the same cloneable object, if the underlying
state machine is anyway synchronized.
Required Methods§
sourcefn build_snapshot<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Snapshot<C::NodeId, C::Node, SD>, StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn build_snapshot<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<Snapshot<C::NodeId, C::Node, SD>, StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Build snapshot
A snapshot has to contain information about exactly all logs up to the last applied.
Building snapshot can be done by:
- Performing log compaction, e.g. merge log entries that operates on the same key, like a LSM-tree does,
- or by fetching a snapshot from the state machine.