Skip to main content

OooBuffer

Struct OooBuffer 

Source
pub struct OooBuffer<L, E>
where L: LogId, E: Extensions,
{ /* private fields */ }
Available on crate feature ingest only.
Expand description

Out-of-order (ooo) buffer allowing a configurable window for handling operations with no predecessors yet.

For every operation this buffer checks if it arrived out-of-order. If yes, it is stored in the internal ring-buffer. If the buffer runs full the oldest item gets evicted first.

§Example

If a log is at log height [1] (frontier) and an operation of sequence number [3] arrives, it can not be appended to the log due to the strict nature of an append-only log. It will be pushed into the buffer, awaiting the missing [2] operation:

         [0] <- [1] <- Log in database

[3] <- Incoming operation

=> Push into ooo-Buffer.

Operation [2] arrives which will “free” the out-of-order items in the buffer, making them “in order”. It will release them from the buffer and forward to the user for further validation and finally insertion into the database:

         [0] <- [1] <- Log in database

         [3] <- Operation in ooo-Buffer

[2] <- Incoming operation

=> Return [2, 3]

§Assumptions

Please make sure to only process items which have been checked before against:

  1. Incoming operations from tombstoned logs / topics were filtered out before.
  2. Duplicate, already ingested operations have been filtered out before.

Implementations§

Source§

impl<L, E> OooBuffer<L, E>
where L: LogId, E: Extensions,

Source

pub fn new() -> OooBuffer<L, E>

Source

pub fn with_capacity(capacity: usize) -> OooBuffer<L, E>

Source

pub async fn len(&self) -> usize

Source

pub async fn is_empty(&self) -> bool

Source

pub async fn clear(&self)

Source

pub async fn process<'a>( &self, operation: &'a Operation<E>, latest_header: Option<&AnyHeader>, log_id: &L, prune_flag: bool, ) -> OooResult<'a, E>

Trait Implementations§

Source§

impl<L, E> Clone for OooBuffer<L, E>
where L: Clone + LogId, E: Clone + Extensions,

Source§

fn clone(&self) -> OooBuffer<L, E>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<L, E> Debug for OooBuffer<L, E>
where L: Debug + LogId, E: Debug + Extensions,

Source§

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

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

impl<L, E> Default for OooBuffer<L, E>
where L: LogId, E: Extensions,

Source§

fn default() -> OooBuffer<L, E>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<L, E> !RefUnwindSafe for OooBuffer<L, E>

§

impl<L, E> !UnwindSafe for OooBuffer<L, E>

§

impl<L, E> Forget for OooBuffer<L, E>

§

impl<L, E> Freeze for OooBuffer<L, E>
where Arc<Mutex<ChainRing<Hash, L, Operation<E>>>>: Freeze,

§

impl<L, E> Send for OooBuffer<L, E>
where Arc<Mutex<ChainRing<Hash, L, Operation<E>>>>: Send,

§

impl<L, E> Sync for OooBuffer<L, E>
where Arc<Mutex<ChainRing<Hash, L, Operation<E>>>>: Sync,

§

impl<L, E> Unpin for OooBuffer<L, E>
where Arc<Mutex<ChainRing<Hash, L, Operation<E>>>>: Unpin,

§

impl<L, E> UnsafeUnpin for OooBuffer<L, E>
where Arc<Mutex<ChainRing<Hash, L, Operation<E>>>>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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