Struct openraft::StoreExt

source ·
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>

source

pub fn new(inner: T) -> Self

Create a StoreExt backed by another store.

source

pub fn set_delay_log_read(&self, ms: u64)

Trait Implementations§

source§

impl<C: RaftTypeConfig, T: RaftStorage<C> + Clone> Clone for StoreExt<C, T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

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,

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. 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,

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

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

source§

fn set_defensive(&self, d: bool)

Enable or disable defensive check when calling storage APIs.
source§

fn is_defensive(&self) -> bool

source§

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>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

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,

Get a series of log entries from storage. Read more
source§

fn get_log_state<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<LogState<C>, StorageError<C::NodeId>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Returns the last deleted log id and the last log id. Read more
source§

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

§

type SnapshotData = <T as RaftStorage<C>>::SnapshotData

The storage engine’s associated type used for exposing a snapshot for reading & writing. Read more
§

type LogReader = LogReaderExt<C, T>

Log reader type.
§

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,

To ensure correctness: the vote must be persisted on disk before returning.
source§

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,

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,

Delete conflict log entries since log_id, inclusive. Read more
source§

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 more
source§

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,

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,

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,

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,

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,

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,

Get the snapshot builder for the state machine. Read more
source§

impl<C, T, SM> RaftStorageDebug<SM> for StoreExt<C, T>where T: RaftStorage<C> + RaftStorageDebug<SM>, C: RaftTypeConfig,

source§

fn get_state_machine<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = SM> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Get a handle to the state machine for testing purposes.
source§

impl<C, BaseStore, BaseBuilder> StoreBuilder<C, StoreExt<C, BaseStore>> for DefensiveStoreBuilder<C, BaseStore, BaseBuilder>where C: RaftTypeConfig, C::D: AppData + Debug, C::R: AppDataResponse + Debug, BaseStore: RaftStorage<C>, BaseBuilder: StoreBuilder<C, BaseStore>,

source§

fn run_test<'life0, 'async_trait, Fun, Ret, Res>( &'life0 self, t: Fun ) -> Pin<Box<dyn Future<Output = Result<Ret, StorageError<C::NodeId>>> + Send + 'async_trait>>where Res: Future<Output = Result<Ret, StorageError<C::NodeId>>> + Send + 'async_trait, Fun: Fn(StoreExt<C, BaseStore>) -> Res + Sync + Send + 'async_trait, Ret: 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

source§

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

source§

fn inner(&mut self) -> &mut T

Auto Trait Implementations§

§

impl<C, T> RefUnwindSafe for StoreExt<C, T>where C: RefUnwindSafe, T: RefUnwindSafe,

§

impl<C, T> Send for StoreExt<C, T>

§

impl<C, T> Sync for StoreExt<C, T>

§

impl<C, T> Unpin for StoreExt<C, T>where C: Unpin, T: Unpin,

§

impl<C, T> UnwindSafe for StoreExt<C, T>where C: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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> 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 Twhere U: From<T>,

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

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
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
source§

impl<T> AppData for Twhere T: Clone + Send + Sync + 'static + OptionalSerde,

source§

impl<T> AppDataResponse for Twhere T: Send + Sync + 'static + OptionalSerde,