Skip to main content

Store

Trait Store 

Source
pub trait Store: Send + Sync {
    // Required methods
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 FleetEvent,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn replay<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stream_key: &'life1 str,
        from_seq: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<FleetEvent>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn high_water<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stream_key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn writable<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn prune<'life0, 'life1, 'async_trait>(
        &'life0 self,
        before_ts: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn usage<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        since: &'life1 str,
        until: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<UsageRow>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

A durable, append-only event log keyed by stream.

Required Methods§

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 FleetEvent, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Append one event to durable storage.

Source

fn replay<'life0, 'life1, 'async_trait>( &'life0 self, stream_key: &'life1 str, from_seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<FleetEvent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Replay events for one stream with seq >= from_seq, in seq order.

Source

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

The highest seq ever persisted for stream_key (0 if none). Used to resume that stream’s sequence counter across daemon restarts.

Source

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

Whether the backend can currently accept writes. A cheap, non-destructive probe used by the readiness endpoint.

Source

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

Delete events with ts < before_ts (RFC-3339, lexically ordered). Returns the number removed. Backs age-based retention (#4).

Source

fn usage<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, since: &'life1 str, until: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<UsageRow>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Aggregate cost, turns, and terminal outcomes per (workspace, UTC day) over [since, until) (RFC-3339, lexically ordered like Store::prune).

Deliberately not a default method: a backend that silently returned nothing here would make the usage endpoint report zero spend rather than fail, which is worse than a compile error. Every backend implements it, and testkit::store_usage_conformance holds them to identical semantics.

Implementors§