pub struct InMemoryRepository { /* private fields */ }Expand description
In-memory repository implementation using HashMap.
This repository is cheap to clone because it uses Arc<RwLock<...>>
internally - cloning creates another handle to the same storage.
Also includes an embedded InMemoryReadModelStore for read model storage.
Its consumer inbox is dev-only: the dedup set grows unbounded (no TTL, no timestamps) and exists for tests and local development. Use the Postgres or SQLite repository for a production inbox with retention control.
Implementations§
Source§impl InMemoryRepository
impl InMemoryRepository
Sourcepub fn with_projection_change_retention(
self,
retention: ProjectionChangeRetention,
) -> Self
pub fn with_projection_change_retention( self, retention: ProjectionChangeRetention, ) -> Self
Configure the maximum newest projection changes retained per partition.
The persisted compacted-through watermark remains authoritative when this value is lengthened; previously compacted changes are never advertised as restored.
Sourcepub fn outbox_store(&self) -> InMemoryOutboxStore
pub fn outbox_store(&self) -> InMemoryOutboxStore
Access the in-memory outbox table handle.
Sourcepub fn model_store(&self) -> &InMemoryReadModelStore
pub fn model_store(&self) -> &InMemoryReadModelStore
Access the embedded read model store directly.
Sourcepub fn snapshot_store(&self) -> &InMemorySnapshotStore
pub fn snapshot_store(&self) -> &InMemorySnapshotStore
Access the embedded snapshot store directly.
Sourcepub fn inbox_contains(&self, consumer: &str, message_id: &str) -> bool
pub fn inbox_contains(&self, consumer: &str, message_id: &str) -> bool
Whether a consumer inbox receipt for (consumer, message_id) is recorded.
Sourcepub fn clear_inbox(&self) -> usize
pub fn clear_inbox(&self) -> usize
Drop every recorded inbox receipt, returning the count removed.
The in-memory equivalent of inbox retention: because this dev-only inbox keeps no timestamps it cannot purge by age, so the only available control is to clear it wholesale (e.g. between test cases).
Trait Implementations§
Source§impl Clone for InMemoryRepository
impl Clone for InMemoryRepository
Source§fn clone(&self) -> InMemoryRepository
fn clone(&self) -> InMemoryRepository
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for InMemoryRepository
impl Default for InMemoryRepository
Source§impl GetStream for InMemoryRepository
impl GetStream for InMemoryRepository
fn get_stream<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<Option<Entity>, RepositoryError>> + Send + 'a
Source§fn get_streams<'a>(
&'a self,
identities: &'a [StreamIdentity],
) -> impl Future<Output = Result<Vec<Entity>, RepositoryError>> + Send + 'a
fn get_streams<'a>( &'a self, identities: &'a [StreamIdentity], ) -> impl Future<Output = Result<Vec<Entity>, RepositoryError>> + Send + 'a
Source§fn get_stream_tail<'a>(
&'a self,
identity: &'a StreamIdentity,
after_version: u64,
) -> impl Future<Output = Result<Option<Entity>, RepositoryError>> + Send + 'a
fn get_stream_tail<'a>( &'a self, identity: &'a StreamIdentity, after_version: u64, ) -> impl Future<Output = Result<Option<Entity>, RepositoryError>> + Send + 'a
sequence > after_version as a tail-only
Entity (see Entity::load_tail_from_history). Read moreSource§impl HasOutboxStore for InMemoryRepository
impl HasOutboxStore for InMemoryRepository
Source§type OutboxStore = InMemoryOutboxStore
type OutboxStore = InMemoryOutboxStore
Source§fn outbox_store(&self) -> Self::OutboxStore
fn outbox_store(&self) -> Self::OutboxStore
Source§impl InboxStore for InMemoryRepository
impl InboxStore for InMemoryRepository
fn inbox_contains<'a>( &'a self, consumer: &'a str, message_id: &'a str, ) -> impl Future<Output = Result<bool, RepositoryError>> + Send + 'a
Source§fn purge_inbox_older_than(
&self,
_age: Duration,
) -> impl Future<Output = Result<u64, RepositoryError>> + Send
fn purge_inbox_older_than( &self, _age: Duration, ) -> impl Future<Output = Result<u64, RepositoryError>> + Send
age, returning the number removed. Read moreSource§impl ReadModelWritePlanStore for InMemoryRepository
impl ReadModelWritePlanStore for InMemoryRepository
fn read_model_capabilities(&self) -> TableAdapterCapabilities
fn commit_write_plan( &self, plan: TableWritePlan, ) -> impl Future<Output = Result<TableCommitOutcome, TableStoreError>> + Send + '_
Source§impl RelationalReadModelQueryStore for InMemoryRepository
impl RelationalReadModelQueryStore for InMemoryRepository
fn read_model_query_capabilities(&self) -> ReadModelQueryCapabilities
fn load_graph( &self, request: ReadModelLoadRequest, ) -> impl Future<Output = Result<ReadModelLoadGraph, TableStoreError>> + Send + '_
Source§impl SnapshotStore for InMemoryRepository
impl SnapshotStore for InMemoryRepository
fn get_snapshot<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<Option<SnapshotRecord>, RepositoryError>> + Send + 'a
Source§fn get_snapshots<'a>(
&'a self,
identities: &'a [StreamIdentity],
) -> impl Future<Output = Result<Vec<SnapshotRecord>, RepositoryError>> + Send + 'a
fn get_snapshots<'a>( &'a self, identities: &'a [StreamIdentity], ) -> impl Future<Output = Result<Vec<SnapshotRecord>, RepositoryError>> + Send + 'a
fn save_snapshot<'a>( &'a self, identity: &'a StreamIdentity, record: SnapshotRecord, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
fn delete_snapshot<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<bool, RepositoryError>> + Send + 'a
Source§impl TransactionalCommit for InMemoryRepository
impl TransactionalCommit for InMemoryRepository
fn commit_batch<'a>( &'a self, batch: CommitBatch<'a>, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
Auto Trait Implementations§
impl Freeze for InMemoryRepository
impl RefUnwindSafe for InMemoryRepository
impl Send for InMemoryRepository
impl Sync for InMemoryRepository
impl Unpin for InMemoryRepository
impl UnsafeUnpin for InMemoryRepository
impl UnwindSafe for InMemoryRepository
Blanket Implementations§
Source§impl<T> AggregateBuilder for T
impl<T> AggregateBuilder for T
fn aggregate<A: Aggregate>(self) -> AggregateRepository<Self, A>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<R> CommitBuilderExt for Rwhere
R: TransactionalCommit,
impl<R> CommitBuilderExt for Rwhere
R: TransactionalCommit,
Source§fn outbox(&self, msg: OutboxMessage) -> CommitBuilder<'_, Self>
fn outbox(&self, msg: OutboxMessage) -> CommitBuilder<'_, Self>
Source§impl<S> HasReadModelStore for Swhere
S: ReadModelWritePlanStore + RelationalReadModelQueryStore,
impl<S> HasReadModelStore for Swhere
S: ReadModelWritePlanStore + RelationalReadModelQueryStore,
type ReadModelStore = S
fn read_model_store(&self) -> &<S as HasReadModelStore>::ReadModelStore
Source§impl<R> HasRepo for Rwhere
R: Repository,
impl<R> HasRepo for Rwhere
R: Repository,
Source§impl<T> Queueable for T
impl<T> Queueable for T
Source§fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>
fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>
.aggregate::<T>() for per-aggregate serialization over the async
repository surface.