pub trait DefensiveCheck<C, T>: DefensiveCheckBase<C>where
    C: RaftTypeConfig,
    T: RaftStorage<C>,
    Self: Wrapper<C, T>,{
    // Provided methods
    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_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_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_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_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_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_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 { ... }
    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_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_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_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 { ... }
}
Expand description

Defines methods of defensive checks for RaftStorage.

Provided Methods§

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,

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,

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,

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,

Trying to feed in empty entries slice is an inappropriate action.

The impl has to avoid this otherwise it may be a bug.

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,

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,

The entries to append has to be greater than any known log ids

source

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,

source

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,

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,

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,

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,

The log id of the entries to apply has to be greater than the last known one.

Implementors§

source§

impl<C, T> DefensiveCheck<C, T> for StoreExt<C, T>where C: RaftTypeConfig, T: RaftStorage<C>,