pub struct StoreExt<C: RaftTypeConfig, T: RaftStorage<C>> { /* private fields */ }
Expand description
Extended store backed by another impl.
It provides defensive check against input and the state of underlying store. And it provides more APIs.
Implementations§
source§impl<C: RaftTypeConfig, T: RaftStorage<C>> StoreExt<C, T>
impl<C: RaftTypeConfig, T: RaftStorage<C>> StoreExt<C, T>
pub fn set_delay_log_read(&self, ms: u64)
Trait Implementations§
source§impl<C: RaftTypeConfig, T: RaftStorage<C> + Clone> Clone for StoreExt<C, T>
impl<C: RaftTypeConfig, T: RaftStorage<C> + Clone> Clone for StoreExt<C, T>
source§impl<C, T> DefensiveCheck<C, T> for StoreExt<C, T>where
C: RaftTypeConfig,
T: RaftStorage<C>,
impl<C, T> DefensiveCheck<C, T> for StoreExt<C, T>where C: RaftTypeConfig, T: RaftStorage<C>,
source§fn defensive_no_dirty_log<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn defensive_no_dirty_log<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait,
Ensure that logs that have greater index than last_applied should have greater log_id.
Invariant must hold:
log.log_id.index > last_applied.index
implies log.log_id > last_applied
.source§fn defensive_incremental_vote<'life0, 'life1, 'async_trait>(
&'life0 mut self,
vote: &'life1 Vote<C::NodeId>
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn defensive_incremental_vote<'life0, 'life1, 'async_trait>( &'life0 mut self, vote: &'life1 Vote<C::NodeId> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Ensure that current_term must increment for every update, and for every term there could be
only one value for voted_for.
source§fn defensive_consecutive_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn defensive_consecutive_input<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
The log entries fed into a store must be consecutive otherwise it is a bug.
source§fn defensive_nonempty_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn defensive_nonempty_input<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Trying to feed in empty entries slice is an inappropriate action. Read more
source§fn defensive_append_log_index_is_last_plus_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn defensive_append_log_index_is_last_plus_one<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
The entries to append has to be last_log_id.index + 1
source§fn defensive_append_log_id_gt_last<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn defensive_append_log_id_gt_last<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
The entries to append has to be greater than any known log ids
fn defensive_purge_applied_le_last_applied<'life0, 'async_trait>( &'life0 mut self, upto: LogId<C::NodeId> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait,
fn defensive_delete_conflict_gt_last_applied<'life0, 'async_trait>( &'life0 mut self, since: LogId<C::NodeId> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait,
source§fn defensive_apply_index_is_last_applied_plus_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn defensive_apply_index_is_last_applied_plus_one<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
The entries to apply to state machine has to be last_applied_log_id.index + 1
source§fn defensive_half_open_range<'life0, 'async_trait, RB>(
&'life0 self,
range: RB
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
RB: 'async_trait + RangeBounds<u64> + Clone + Debug + Send,
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn defensive_half_open_range<'life0, 'async_trait, RB>( &'life0 self, range: RB ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where RB: 'async_trait + RangeBounds<u64> + Clone + Debug + Send, Self: Sync + 'async_trait, 'life0: 'async_trait,
Requires a range must be at least half open: (-oo, n] or [n, +oo);
In order to keep logs continuity.
source§fn defensive_range_hits_logs<'life0, 'life1, 'async_trait, RB>(
&'life0 self,
range: RB,
logs: &'life1 [Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
RB: 'async_trait + RangeBounds<u64> + Debug + Send,
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn defensive_range_hits_logs<'life0, 'life1, 'async_trait, RB>( &'life0 self, range: RB, logs: &'life1 [Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where RB: 'async_trait + RangeBounds<u64> + Debug + Send, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
An range operation such as get or delete has to actually covers some log entries in store.
source§fn defensive_apply_log_id_gt_last<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn defensive_apply_log_id_gt_last<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
The log id of the entries to apply has to be greater than the last known one.
source§impl<C, T> DefensiveCheckBase<C> for StoreExt<C, T>where
C: RaftTypeConfig,
T: RaftStorage<C>,
impl<C, T> DefensiveCheckBase<C> for StoreExt<C, T>where C: RaftTypeConfig, T: RaftStorage<C>,
source§fn set_defensive(&self, d: bool)
fn set_defensive(&self, d: bool)
Enable or disable defensive check when calling storage APIs.
fn is_defensive(&self) -> bool
source§fn defensive_nonempty_range<RB: RangeBounds<u64> + Clone + Debug + Send>(
&self,
range: RB
) -> Result<(), StorageError<C::NodeId>>
fn defensive_nonempty_range<RB: RangeBounds<u64> + Clone + Debug + Send>( &self, range: RB ) -> Result<(), StorageError<C::NodeId>>
The range must not be empty otherwise it is an inappropriate action.
source§impl<C: RaftTypeConfig, T: RaftStorage<C>> Deref for StoreExt<C, T>
impl<C: RaftTypeConfig, T: RaftStorage<C>> Deref for StoreExt<C, T>
source§impl<C: RaftTypeConfig, T: RaftStorage<C>> RaftLogReader<C> for StoreExt<C, T>
impl<C: RaftTypeConfig, T: RaftStorage<C>> RaftLogReader<C> for StoreExt<C, T>
source§fn try_get_log_entries<'life0, 'async_trait, RB>(
&'life0 mut self,
range: RB
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry<C>>, StorageError<C::NodeId>>> + Send + 'async_trait>>where
RB: 'async_trait + RangeBounds<u64> + Clone + Debug + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
fn try_get_log_entries<'life0, 'async_trait, RB>( &'life0 mut self, range: RB ) -> Pin<Box<dyn Future<Output = Result<Vec<Entry<C>>, StorageError<C::NodeId>>> + Send + 'async_trait>>where RB: 'async_trait + RangeBounds<u64> + Clone + Debug + Send + Sync, Self: 'async_trait, 'life0: 'async_trait,
Get a series of log entries from storage. Read more
source§impl<C, T> RaftStorage<C> for StoreExt<C, T>where
T: RaftStorage<C>,
C: RaftTypeConfig,
impl<C, T> RaftStorage<C> for StoreExt<C, T>where T: RaftStorage<C>, C: RaftTypeConfig,
§type SnapshotData = <T as RaftStorage<C>>::SnapshotData
type SnapshotData = <T as RaftStorage<C>>::SnapshotData
The storage engine’s associated type used for exposing a snapshot for reading & writing. Read more
§type SnapshotBuilder = SnapshotBuilderExt<C, T>
type SnapshotBuilder = SnapshotBuilderExt<C, T>
Snapshot builder type.
source§fn save_vote<'life0, 'life1, 'async_trait>(
&'life0 mut self,
vote: &'life1 Vote<C::NodeId>
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_vote<'life0, 'life1, 'async_trait>( &'life0 mut self, vote: &'life1 Vote<C::NodeId> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
To ensure correctness: the vote must be persisted on disk before returning.
fn read_vote<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<Option<Vote<C::NodeId>>, StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
source§fn last_applied_state<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<(Option<LogId<C::NodeId>>, StoredMembership<C::NodeId, C::Node>), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn last_applied_state<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<(Option<LogId<C::NodeId>>, StoredMembership<C::NodeId, C::Node>), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Returns the last applied log id which is recorded in state machine, and the last applied
membership config. Read more
source§fn delete_conflict_logs_since<'life0, 'async_trait>(
&'life0 mut self,
log_id: LogId<C::NodeId>
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_conflict_logs_since<'life0, 'async_trait>( &'life0 mut self, log_id: LogId<C::NodeId> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Delete conflict log entries since
log_id
, inclusive. Read moresource§fn purge_logs_upto<'life0, 'async_trait>(
&'life0 mut self,
log_id: LogId<C::NodeId>
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn purge_logs_upto<'life0, 'async_trait>( &'life0 mut self, log_id: LogId<C::NodeId> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Delete applied log entries upto
log_id
, inclusive. Read moresource§fn append_to_log<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn append_to_log<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Append a payload of entries to the log. Read more
source§fn apply_to_state_machine<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
entries: &'life1 [&'life2 Entry<C>]
) -> Pin<Box<dyn Future<Output = Result<Vec<C::R>, StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn apply_to_state_machine<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, entries: &'life1 [&'life2 Entry<C>] ) -> Pin<Box<dyn Future<Output = Result<Vec<C::R>, StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,
Apply the given payload of entries to the state machine. Read more
source§fn begin_receiving_snapshot<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Box<Self::SnapshotData>, StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_receiving_snapshot<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<Box<Self::SnapshotData>, StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Create a new blank snapshot, returning a writable handle to the snapshot object. Read more
source§fn install_snapshot<'life0, 'life1, 'async_trait>(
&'life0 mut self,
meta: &'life1 SnapshotMeta<C::NodeId, C::Node>,
snapshot: Box<Self::SnapshotData>
) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn install_snapshot<'life0, 'life1, 'async_trait>( &'life0 mut self, meta: &'life1 SnapshotMeta<C::NodeId, C::Node>, snapshot: Box<Self::SnapshotData> ) -> Pin<Box<dyn Future<Output = Result<(), StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Install a snapshot which has finished streaming from the leader. Read more
source§fn get_current_snapshot<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Option<Snapshot<C::NodeId, C::Node, Self::SnapshotData>>, StorageError<C::NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_current_snapshot<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<Option<Snapshot<C::NodeId, C::Node, Self::SnapshotData>>, StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Get a readable handle to the current snapshot, along with its metadata. Read more
source§fn get_log_reader<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Self::LogReader> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_log_reader<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Self::LogReader> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Get the log reader. Read more
source§fn get_snapshot_builder<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Self::SnapshotBuilder> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_snapshot_builder<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Self::SnapshotBuilder> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Get the snapshot builder for the state machine. Read more