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 atomicallyread- Query events with filtering and paginationget_subscriber_cursor- Get subscription positionis_subscriber_running- Check if subscription is activeupsert_subscriber- Create/update subscriptionacknowledge- Update subscription cursor
Required Methods§
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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.