Skip to main content

BufferedBackend

Struct BufferedBackend 

Source
pub struct BufferedBackend { /* private fields */ }

Implementations§

Source§

impl BufferedBackend

Source

pub fn new(inner: Arc<dyn StorageBackend>, batch_size: usize) -> Self

Wrap inner, writing through once batch_size decisions accumulate. A batch_size of 0 or 1 disables buffering.

Source

pub fn pending(&self) -> usize

Decisions accepted but not yet written to the wrapped backend.

Source

pub fn inner(&self) -> &Arc<dyn StorageBackend> ⓘ

The backend being buffered, for reads that should bypass the buffer.

Trait Implementations§

Source§

impl Drop for BufferedBackend

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl StorageBackend for BufferedBackend

Source§

fn save<'life0, 'life1, 'async_trait>( &'life0 self, snapshot: &'life1 Snapshot, ) -> Pin<Box<dyn Future<Output = Result<String, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Snapshots are not buffered; they go straight through.

Source§

fn save_decision<'life0, 'life1, 'async_trait>( &'life0 self, decision: &'life1 DecisionSnapshot, ) -> Pin<Box<dyn Future<Output = Result<String, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Buffer the decision and return its id immediately. The id is the decision’s own snapshot id, so it is valid before the write lands.

Source§

fn query<'life0, 'async_trait>( &'life0 self, q: SnapshotQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<Snapshot>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queries run against the wrapped backend, so pending decisions are not visible until they are flushed.

Source§

fn flush<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<FlushResult, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write everything pending, then flush the wrapped backend.

snapshots_written counts the decisions this call wrote. Backends report their own totals there (SqliteBackend returns the table’s row count), so the inner figure is deliberately not carried through.

Source§

fn save_decisions<'life0, 'life1, 'async_trait>( &'life0 self, decisions: &'life1 [DecisionSnapshot], ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save many decisions in one round trip, returning their ids in order. Read more
Source§

fn load<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Snapshot, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load a snapshot by ID
Source§

fn load_decision<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<DecisionSnapshot, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load a decision by ID
Source§

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a snapshot
Source§

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check health/connectivity

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

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.