Skip to main content

UsageBackend

Trait UsageBackend 

Source
pub trait UsageBackend: Send + Sync {
    // Required methods
    fn flush<'life0, 'life1, 'async_trait>(
        &'life0 self,
        counters: &'life1 HashMap<(String, String, String), u64>,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<HashMap<(String, String, String), u64>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Persistence backend for usage counters.

Implementations flush the aggregator’s in-memory counters to a durable store and reload them on startup. The default NoopBackend is a no-op that preserves current in-memory-only behaviour.

Required Methods§

Source

fn flush<'life0, 'life1, 'async_trait>( &'life0 self, counters: &'life1 HashMap<(String, String, String), u64>, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Flush all current counter values to the backing store.

The counters map has the form (tenant_id, period_yyyy_mm, entity_type) → count.

§Errors

Returns an error if the backing store is unavailable or the write fails.

Source

fn load<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<(String, String, String), u64>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load all persisted counters from the backing store.

§Errors

Returns an error if the backing store is unavailable or the read fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§