Skip to main content

SignalStore

Trait SignalStore 

Source
pub trait SignalStore: Send + Sync {
    // Required methods
    fn record<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        key: &'life1 SignalKey,
        signal: &'life2 Signal,
        source: &'life3 str,
        at: DateTime<Utc>,
        new_id: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = Result<(SignalRecord, bool)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<SignalRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        filter: &'life1 SignalFilter,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SignalRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn close<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn hit<'life0, 'life1, 'async_trait>(
        &'life0 self,
        source: &'life1 str,
        window_start: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

The signal records of every back-office partition and the per-source rate counters (spec 3.5 §7.10), on in-memory, SQLite, PostgreSQL and Redis.

Required Methods§

Source

fn record<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, key: &'life1 SignalKey, signal: &'life2 Signal, source: &'life3 str, at: DateTime<Utc>, new_id: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<(SignalRecord, bool)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Records signal from source at at under key, atomically: when an open record has the key, raises its count by one and makes signal its latest, returning it and false; otherwise opens a record with id new_id and count 1, returning it and true.

§Errors

Returns KernelError::Store when the backend fails.

Source

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

The record id, or None.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 SignalFilter, ) -> Pin<Box<dyn Future<Output = Result<Vec<SignalRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The records filter selects, oldest first (by first_at, then id).

§Errors

Returns KernelError::Store when the backend fails.

Source

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

Closes the open record id, so the next signal of its key opens a new one; false when no open record has the id.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn hit<'life0, 'life1, 'async_trait>( &'life0 self, source: &'life1 str, window_start: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Counts one signal from source in the rate window starting at window_start, and returns the window’s count with it. Counts of other windows are independent; a backend may forget windows older than a day.

§Errors

Returns KernelError::Store when the backend fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§