pub trait SubscribableStore: EventStore + GloballyOrderedStore {
// Required method
fn subscribe(
&self,
filters: &[EventFilter<Self::Id, Self::Position>],
from_position: Option<Self::Position>,
) -> EventStream<'_, Self>
where Self::Position: Ord;
}Expand description
A store that supports push-based event subscriptions.
Extends EventStore with a subscribe method that returns a stream of
events. The stream replays historical events first, then yields live events
as they are committed.
This is a separate trait (not on EventStore directly) because not all
stores support push notifications. The in-memory store uses
tokio::sync::broadcast; a PostgreSQL implementation would use
LISTEN/NOTIFY.
Required Methods§
Sourcefn subscribe(
&self,
filters: &[EventFilter<Self::Id, Self::Position>],
from_position: Option<Self::Position>,
) -> EventStream<'_, Self>
fn subscribe( &self, filters: &[EventFilter<Self::Id, Self::Position>], from_position: Option<Self::Position>, ) -> EventStream<'_, Self>
Subscribe to events matching the given filters.
Returns a stream that:
- Yields all historical events after
from_position(catch-up phase) - Yields live events as they are committed (live phase)
from_position is exclusive: the stream yields events strictly
after the given position.
Delivery guarantee: at-least-once. The stream may yield duplicate events during the catch-up-to-live transition. The subscription loop deduplicates by position.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.