Skip to main content

EventStore

Trait EventStore 

Source
pub trait EventStore: Send + Sync {
    // Required methods
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
        turn: usize,
        envelope: AgentEventEnvelope,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn finish_turn<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
        turn: usize,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_turn<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
        turn: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Option<StoredTurnEvents>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_turns<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTurnEvents>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn get_events<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for storing and retrieving turn-scoped event streams.

Event writes are split into two phases:

  1. append records individual envelopes
  2. finish_turn marks the authoritative close barrier

Required Methods§

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, turn: usize, envelope: AgentEventEnvelope, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Append an event envelope for the given thread and turn.

§Errors

Returns an error if the event cannot be persisted.

Source

fn finish_turn<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, turn: usize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mark the given turn as finished and flush any buffered writes.

§Errors

Returns an error if the store cannot durably close the turn.

Source

fn get_turn<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, turn: usize, ) -> Pin<Box<dyn Future<Output = Result<Option<StoredTurnEvents>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve the stored data for a single turn.

§Errors

Returns an error if the turn cannot be retrieved.

Source

fn get_turns<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredTurnEvents>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve all stored turns for the given thread in ascending turn order.

§Errors

Returns an error if the thread history cannot be retrieved.

Source

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

Clear all events for the given thread.

§Errors

Returns an error if the thread cannot be cleared.

Provided Methods§

Source

fn get_events<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<Vec<AgentEventEnvelope>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve all event envelopes for the given thread across every stored turn.

§Errors

Returns an error if the thread history cannot be retrieved.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§