pub trait EventDag: Send + Sync {
type Payload: Clone + Send + Sync + 'static;
// Required methods
fn append<'life0, 'async_trait>(
&'life0 self,
event: Event<Self::Payload>,
) -> Pin<Box<dyn Future<Output = Effect<EventId>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn read<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
) -> Pin<Box<dyn Future<Output = Effect<Event<Self::Payload>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn walk_ancestors<'life0, 'async_trait>(
&'life0 self,
from: EventId,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn walk_descendants<'life0, 'async_trait>(
&'life0 self,
from: EventId,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn signal_upstream<'life0, 'async_trait>(
&'life0 self,
from: EventId,
signal: UpstreamSignal,
) -> Pin<Box<dyn Future<Output = Effect<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn find_correlation_chain<'life0, 'async_trait>(
&'life0 self,
tenant_id: Uuid,
correlation_id: EventId,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn next_position<'life0, 'async_trait>(
&'life0 self,
parent: Option<EventId>,
lane: u32,
) -> Pin<Box<dyn Future<Output = Effect<DagPosition>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn find_by_kind<'life0, 'async_trait>(
&'life0 self,
kind: EventKind,
min_depth: u32,
max_depth: u32,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn acknowledge<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
send_upstream: bool,
) -> Pin<Box<dyn Future<Output = Effect<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn unacknowledged<'life0, 'async_trait>(
&'life0 self,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn find_by_kind_for_tenant<'life0, 'async_trait>(
&'life0 self,
tenant_id: Uuid,
kind: EventKind,
min_depth: u32,
max_depth: u32,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for Event DAG operations.
Implementations of this trait provide persistent storage and traversal of the event graph. The DAG supports:
- Appending new events with automatic position calculation
- Reading events by ID
- Walking ancestor chains for context reconstruction
- Sending upstream signals for coordination
- Correlation chain traversal for related event discovery
§Async Design
All methods are async to support:
- LMDB hot cache (sync but fast - microseconds, safe in async context)
- PostgreSQL fallback (truly async - milliseconds, non-blocking)
§Payload Type
The Payload associated type determines what data is stored with each event.
This is typically a serializable enum of all possible event payloads.
Required Associated Types§
Required Methods§
Sourcefn append<'life0, 'async_trait>(
&'life0 self,
event: Event<Self::Payload>,
) -> Pin<Box<dyn Future<Output = Effect<EventId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append<'life0, 'async_trait>(
&'life0 self,
event: Event<Self::Payload>,
) -> Pin<Box<dyn Future<Output = Effect<EventId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Append a new event to the DAG.
The event’s position should be set by the caller based on the parent event. Returns the assigned event ID on success.
Sourcefn read<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
) -> Pin<Box<dyn Future<Output = Effect<Event<Self::Payload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
) -> Pin<Box<dyn Future<Output = Effect<Event<Self::Payload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read an event by its ID.
Sourcefn walk_ancestors<'life0, 'async_trait>(
&'life0 self,
from: EventId,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn walk_ancestors<'life0, 'async_trait>(
&'life0 self,
from: EventId,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Walk the ancestor chain from a given event.
Returns events from from toward the root, limited by limit.
The events are returned in order from most recent to oldest.
Sourcefn walk_descendants<'life0, 'async_trait>(
&'life0 self,
from: EventId,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn walk_descendants<'life0, 'async_trait>(
&'life0 self,
from: EventId,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Walk descendants from a given event.
Sourcefn signal_upstream<'life0, 'async_trait>(
&'life0 self,
from: EventId,
signal: UpstreamSignal,
) -> Pin<Box<dyn Future<Output = Effect<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn signal_upstream<'life0, 'async_trait>(
&'life0 self,
from: EventId,
signal: UpstreamSignal,
) -> Pin<Box<dyn Future<Output = Effect<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send an upstream signal from a downstream event.
Signals propagate backward through the DAG to notify upstream producers of acknowledgments, backpressure, or errors.
Sourcefn find_correlation_chain<'life0, 'async_trait>(
&'life0 self,
tenant_id: Uuid,
correlation_id: EventId,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_correlation_chain<'life0, 'async_trait>(
&'life0 self,
tenant_id: Uuid,
correlation_id: EventId,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Find all events in a correlation chain.
Sourcefn next_position<'life0, 'async_trait>(
&'life0 self,
parent: Option<EventId>,
lane: u32,
) -> Pin<Box<dyn Future<Output = Effect<DagPosition>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_position<'life0, 'async_trait>(
&'life0 self,
parent: Option<EventId>,
lane: u32,
) -> Pin<Box<dyn Future<Output = Effect<DagPosition>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the current position for appending a new event.
Sourcefn find_by_kind<'life0, 'async_trait>(
&'life0 self,
kind: EventKind,
min_depth: u32,
max_depth: u32,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_by_kind<'life0, 'async_trait>(
&'life0 self,
kind: EventKind,
min_depth: u32,
max_depth: u32,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get events by kind within a position range.
Provided Methods§
Sourcefn find_by_kind_for_tenant<'life0, 'async_trait>(
&'life0 self,
tenant_id: Uuid,
kind: EventKind,
min_depth: u32,
max_depth: u32,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_by_kind_for_tenant<'life0, 'async_trait>(
&'life0 self,
tenant_id: Uuid,
kind: EventKind,
min_depth: u32,
max_depth: u32,
limit: usize,
) -> Pin<Box<dyn Future<Output = Effect<Vec<Event<Self::Payload>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get events by kind within a position range for a tenant.
Default behavior falls back to find_by_kind for implementations that
do not support tenant-scoped querying at the storage boundary.