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 replay_fleet<'life0, 'async_trait>(
        &'life0 self,
        after_cursor: u64,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CursoredEvent>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn latest_fleet_cursor<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: '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 replay_fleet<'life0, 'async_trait>( &'life0 self, after_cursor: u64, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<CursoredEvent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Replay every stream’s events after after_cursor, in durable insertion order, at most limit of them (#219).

Per-stream seq cannot order a fleet — two agents both have a seq 1 — so each event carries a fleet-wide CursoredEvent::cursor, the backend’s own insertion order. That cursor is what a resuming client hands back, so it is exclusive on after_cursor, strictly increasing, and stable once written. limit bounds the batch so a long history resumes in chunks rather than one unbounded read.

Source

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

The newest fleet cursor, or 0 when nothing is stored (#219).

This is where a from=now subscriber starts: it wants what happens next, not the history, and replay_fleet is exclusive on its argument.

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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§