pub struct EventStore { /* private fields */ }Expand description
A robust, in-memory event store. Supports append-only storage, subscriber tracking, and garbage collection.
Implementations§
Source§impl EventStore
impl EventStore
pub fn new(retention_policy: RetentionPolicy) -> Self
Sourcepub async fn append(&self, event: CanonicalMessage) -> u64
pub async fn append(&self, event: CanonicalMessage) -> u64
Appends an event to the store. Assigns an offset and stored_at timestamp to the message metadata.
Sourcepub async fn append_batch(&self, messages: Vec<CanonicalMessage>) -> u64
pub async fn append_batch(&self, messages: Vec<CanonicalMessage>) -> u64
Appends a batch of events to the store.
pub fn with_drop_callback( self, callback: impl Fn(Vec<StoredEvent>) + Send + Sync + 'static, ) -> Self
Sourcepub async fn register_subscriber(&self, subscriber_id: String)
pub async fn register_subscriber(&self, subscriber_id: String)
Registers a subscriber or updates its liveness.
Sourcepub async fn ack(&self, subscriber_id: &str, offset: u64)
pub async fn ack(&self, subscriber_id: &str, offset: u64)
Acknowledges processing of events up to offset for a subscriber.
Triggers Garbage Collection.
Sourcepub async fn get_events_since(
&self,
last_known_offset: u64,
limit: usize,
) -> Result<Vec<StoredEvent>, ConsumerError>
pub async fn get_events_since( &self, last_known_offset: u64, limit: usize, ) -> Result<Vec<StoredEvent>, ConsumerError>
Returns events with offset > last_known_offset.
If the requested events have already been GC’d (i.e. there’s a gap between
last_known_offset + 1 and the current base_offset), returns Err(ConsumerError::Gap).
Sourcepub async fn wait_for_events(&self, last_known_offset: u64)
pub async fn wait_for_events(&self, last_known_offset: u64)
Waits for new events if none are currently available after last_known_offset.
pub fn consumer(self: &Arc<Self>, subscriber_id: String) -> EventStoreConsumer
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EventStore
impl !RefUnwindSafe for EventStore
impl !UnwindSafe for EventStore
impl Send for EventStore
impl Sync for EventStore
impl Unpin for EventStore
impl UnsafeUnpin for EventStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more