pub trait PersistenceBackend: Send + Sync {
// Required methods
fn store<'a>(
&'a self,
record_name: &'a str,
value: &'a Value,
timestamp: u64,
) -> BoxFuture<'a, Result<(), PersistenceError>>;
fn query<'a>(
&'a self,
record_pattern: &'a str,
params: QueryParams,
) -> BoxFuture<'a, Result<Vec<StoredValue>, PersistenceError>>;
fn cleanup(
&self,
older_than: u64,
) -> BoxFuture<'_, Result<u64, PersistenceError>>;
// Provided method
fn initialize(&self) -> BoxFuture<'_, Result<(), PersistenceError>> { ... }
}Expand description
Pluggable persistence backend.
Implementations run on a concrete async runtime (e.g. Tokio). The trait
uses manual BoxFuture instead of async_trait for consistency with the
rest of the AimDB codebase.
Required Methods§
Sourcefn store<'a>(
&'a self,
record_name: &'a str,
value: &'a Value,
timestamp: u64,
) -> BoxFuture<'a, Result<(), PersistenceError>>
fn store<'a>( &'a self, record_name: &'a str, value: &'a Value, timestamp: u64, ) -> BoxFuture<'a, Result<(), PersistenceError>>
Store a JSON value for a record.
Sourcefn query<'a>(
&'a self,
record_pattern: &'a str,
params: QueryParams,
) -> BoxFuture<'a, Result<Vec<StoredValue>, PersistenceError>>
fn query<'a>( &'a self, record_pattern: &'a str, params: QueryParams, ) -> BoxFuture<'a, Result<Vec<StoredValue>, PersistenceError>>
Query stored values, with optional pattern and time-range support.
record_pattern supports * as a glob wildcard. For example,
"accuracy::*" matches all records whose name starts with "accuracy::".
Provided Methods§
Sourcefn initialize(&self) -> BoxFuture<'_, Result<(), PersistenceError>>
fn initialize(&self) -> BoxFuture<'_, Result<(), PersistenceError>>
Initialize storage (create tables, indexes, …).
Default: no-op. Backends that perform setup eagerly in ::new()
(like SqliteBackend) do not need to override this.