Skip to main content

Executor

Trait Executor 

Source
pub trait Executor:
    Send
    + Sync
    + 'static {
    // Required methods
    fn write<'life0, 'async_trait>(
        &'life0 self,
        events: Vec<Event>,
    ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_subscriber_cursor<'life0, 'async_trait>(
        &'life0 self,
        key: String,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_subscriber_running<'life0, 'async_trait>(
        &'life0 self,
        key: String,
        worker_id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn upsert_subscriber<'life0, 'async_trait>(
        &'life0 self,
        key: String,
        worker_id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn acknowledge<'life0, 'async_trait>(
        &'life0 self,
        key: String,
        cursor: Value,
        lag: u64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn read<'life0, 'async_trait>(
        &'life0 self,
        aggregators: Option<Vec<ReadAggregator>>,
        routing_key: Option<RoutingKey>,
        args: Args,
    ) -> Pin<Box<dyn Future<Output = Result<ReadResult<Event>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_snapshot<'life0, 'async_trait>(
        &'life0 self,
        aggregator_type: String,
        aggregator_revision: String,
        id: String,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, Value)>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn save_snapshot<'life0, 'async_trait>(
        &'life0 self,
        aggregator_type: String,
        aggregator_revision: String,
        id: String,
        data: Vec<u8>,
        cursor: Value,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Core trait for event storage backends.

Implementations handle persisting events, querying, and managing subscriptions. The main implementation is evento_sql::Sql.

§Methods

  • write - Persist events atomically
  • read - Query events with filtering and pagination
  • get_subscriber_cursor - Get subscription position
  • is_subscriber_running - Check if subscription is active
  • upsert_subscriber - Create/update subscription
  • acknowledge - Update subscription cursor

Required Methods§

Source

fn write<'life0, 'async_trait>( &'life0 self, events: Vec<Event>, ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persists events atomically.

Returns WriteError::InvalidOriginalVersion if version conflicts occur.

Source

fn get_subscriber_cursor<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<Option<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the current cursor position for a subscription.

Source

fn is_subscriber_running<'life0, 'async_trait>( &'life0 self, key: String, worker_id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if a subscription is running with the given worker ID.

Source

fn upsert_subscriber<'life0, 'async_trait>( &'life0 self, key: String, worker_id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates or updates a subscription record.

Source

fn acknowledge<'life0, 'async_trait>( &'life0 self, key: String, cursor: Value, lag: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates subscription cursor after processing events.

Source

fn read<'life0, 'async_trait>( &'life0 self, aggregators: Option<Vec<ReadAggregator>>, routing_key: Option<RoutingKey>, args: Args, ) -> Pin<Box<dyn Future<Output = Result<ReadResult<Event>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queries events with filtering and pagination.

Source

fn get_snapshot<'life0, 'async_trait>( &'life0 self, aggregator_type: String, aggregator_revision: String, id: String, ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, Value)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves a stored snapshot for an aggregate.

Returns the serialized snapshot data and cursor position, or None if no snapshot exists for the given aggregate.

Source

fn save_snapshot<'life0, 'async_trait>( &'life0 self, aggregator_type: String, aggregator_revision: String, id: String, data: Vec<u8>, cursor: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores a snapshot for an aggregate.

Snapshots cache aggregate state to avoid replaying all events. The cursor indicates the event position up to which the snapshot is valid.

Implementors§