pub struct BufferedBackend { /* private fields */ }Implementations§
Source§impl BufferedBackend
impl BufferedBackend
Sourcepub fn new(inner: Arc<dyn StorageBackend>, batch_size: usize) -> Self
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.
Sourcepub fn inner(&self) -> &Arc<dyn StorageBackend> ⓘ
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
impl Drop for BufferedBackend
Source§impl StorageBackend for BufferedBackend
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,
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,
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 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,
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,
Pending decisions are written through first, so a decision saved a moment ago is loadable as a snapshot like any flushed one.
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,
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,
Pending decisions are written through before the query runs, so the wrapped backend’s filtering, ordering and pagination apply to them too.
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,
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.