Skip to main content

SnapshotLoader

Trait SnapshotLoader 

Source
pub trait SnapshotLoader:
    Send
    + Sync
    + 'static {
    type Snapshot: Send + Sync;

    const NAME: &'static str;

    // Required methods
    fn fetch<'life0, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Snapshot, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn count_refresh_error();
}
Expand description

What a SnapshotSource needs from a specific store: how to fetch a fresh snapshot from the pool, and the name/metric to report on a refresh failure.

Required Associated Constants§

Source

const NAME: &'static str

Human-readable store name used in error/log text (e.g. “audience grant store”, “group store”).

Required Associated Types§

Source

type Snapshot: Send + Sync

The loaded, ready-to-serve snapshot type (e.g. AudienceGrants, GroupGraph).

Required Methods§

Source

fn fetch<'life0, 'async_trait>( pool: &'life0 Pool<Postgres>, ) -> Pin<Box<dyn Future<Output = Result<Self::Snapshot, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Queries the whole table(s) and builds a fresh snapshot.

Source

fn count_refresh_error()

Emits this store’s own refresh-error metric (imetric!() with its own literal name) – called by SnapshotSource::current at both failure sites.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl SnapshotLoader for AudienceGrantsLoader

Source§

const NAME: &'static str = "audience grant store"

Source§

type Snapshot = AudienceGrants

Source§

impl SnapshotLoader for GroupsLoader

Source§

const NAME: &'static str = "group store"

Source§

type Snapshot = GroupGraph