pub struct MemoryEventStore { /* private fields */ }Expand description
In-memory EventStore with a per-session ring buffer.
Each session keeps up to max_events_per_session events; the oldest is
evicted when the buffer is full. This is the default store; external
implementations are only needed for cross-instance replay.
Implementations§
Source§impl MemoryEventStore
impl MemoryEventStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new store using DEFAULT_MAX_EVENTS_PER_SESSION.
Sourcepub fn with_capacity(max_events_per_session: usize) -> Self
pub fn with_capacity(max_events_per_session: usize) -> Self
Create a store with the given per-session buffer capacity.
Sourcepub async fn total_events(&self) -> usize
pub async fn total_events(&self) -> usize
Total number of events currently buffered across all sessions.
Sourcepub async fn session_count(&self) -> usize
pub async fn session_count(&self) -> usize
Number of sessions with at least one buffered event.
Trait Implementations§
Source§impl Clone for MemoryEventStore
impl Clone for MemoryEventStore
Source§fn clone(&self) -> MemoryEventStore
fn clone(&self) -> MemoryEventStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryEventStore
impl Debug for MemoryEventStore
Source§impl Default for MemoryEventStore
impl Default for MemoryEventStore
Source§impl EventStore for MemoryEventStore
impl EventStore for MemoryEventStore
Source§fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
event: EventRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
event: EventRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Append an event to a session’s log.
Source§fn replay_after<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
after_id: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn replay_after<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
after_id: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return events with IDs strictly greater than
after_id, in order.Auto Trait Implementations§
impl !RefUnwindSafe for MemoryEventStore
impl !UnwindSafe for MemoryEventStore
impl Freeze for MemoryEventStore
impl Send for MemoryEventStore
impl Sync for MemoryEventStore
impl Unpin for MemoryEventStore
impl UnsafeUnpin for MemoryEventStore
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