pub struct QueuedRepository<R, L = InMemoryAsyncLockManager> { /* private fields */ }Expand description
Repository wrapper that serializes access with process-local per-stream locks.
Locking reads (get and get_many) intentionally keep matching locks held
after returning. Call commit to release those locks after a successful
write, or call abort/unlock when the loaded entity is no longer being
written. Dropping a loaded entity without commit or abort leaves its
in-memory lock held until an explicit unlock.
Commit releases held locks only after the inner repository succeeds. On commit errors, locks remain held so callers can inspect state, retry, or explicitly abort.
Implementations§
Source§impl<R> QueuedRepository<R>
impl<R> QueuedRepository<R>
Source§impl<R, L> QueuedRepository<R, L>
impl<R, L> QueuedRepository<R, L>
Source§impl<R, L: AsyncLockManager> QueuedRepository<R, L>
impl<R, L: AsyncLockManager> QueuedRepository<R, L>
Sourcepub fn with_async_lock_manager(inner: R, lock_manager: L) -> Self
pub fn with_async_lock_manager(inner: R, lock_manager: L) -> Self
Create a QueuedRepository with a custom async lock manager.
Trait Implementations§
Source§impl<R, L> AsyncGetAllWithOpts for QueuedRepository<R, L>where
R: AsyncGetStream,
L: AsyncLockManager,
impl<R, L> AsyncGetAllWithOpts for QueuedRepository<R, L>where
R: AsyncGetStream,
L: AsyncLockManager,
fn get_streams_with<'a>( &'a self, identities: &'a [StreamIdentity], opts: ReadOpts, ) -> impl Future<Output = Result<Vec<Entity>, RepositoryError>> + Send + 'a
Source§impl<R, L> AsyncGetStream for QueuedRepository<R, L>where
R: AsyncGetStream,
L: AsyncLockManager,
impl<R, L> AsyncGetStream for QueuedRepository<R, L>where
R: AsyncGetStream,
L: AsyncLockManager,
fn get_stream<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<Option<Entity>, RepositoryError>> + Send + 'a
fn get_streams<'a>( &'a self, identities: &'a [StreamIdentity], ) -> impl Future<Output = Result<Vec<Entity>, RepositoryError>> + Send + 'a
Source§impl<R, L> AsyncGetWithOpts for QueuedRepository<R, L>where
R: AsyncGetStream,
L: AsyncLockManager,
impl<R, L> AsyncGetWithOpts for QueuedRepository<R, L>where
R: AsyncGetStream,
L: AsyncLockManager,
fn get_stream_with<'a>( &'a self, identity: &'a StreamIdentity, opts: ReadOpts, ) -> impl Future<Output = Result<Option<Entity>, RepositoryError>> + Send + 'a
Source§impl<R, L> AsyncInboxStore for QueuedRepository<R, L>where
R: AsyncInboxStore,
L: AsyncLockManager,
impl<R, L> AsyncInboxStore for QueuedRepository<R, L>where
R: AsyncInboxStore,
L: AsyncLockManager,
fn inbox_contains_async<'a>( &'a self, consumer: &'a str, message_id: &'a str, ) -> impl Future<Output = Result<bool, RepositoryError>> + Send + 'a
Source§impl<R, L> AsyncReadModelWritePlanStore for QueuedRepository<R, L>where
R: AsyncReadModelWritePlanStore,
L: AsyncLockManager,
impl<R, L> AsyncReadModelWritePlanStore for QueuedRepository<R, L>where
R: AsyncReadModelWritePlanStore,
L: AsyncLockManager,
fn read_model_capabilities_async(&self) -> ReadModelAdapterCapabilities
fn commit_write_plan_async( &self, plan: ReadModelWritePlan, ) -> impl Future<Output = Result<ReadModelCommitOutcome, ReadModelError>> + Send + '_
Source§impl<R, L> AsyncRelationalReadModelQueryStore for QueuedRepository<R, L>where
R: AsyncRelationalReadModelQueryStore,
L: AsyncLockManager,
impl<R, L> AsyncRelationalReadModelQueryStore for QueuedRepository<R, L>where
R: AsyncRelationalReadModelQueryStore,
L: AsyncLockManager,
fn read_model_query_capabilities_async(&self) -> ReadModelQueryCapabilities
fn load_graph_async( &self, request: ReadModelLoadRequest, ) -> impl Future<Output = Result<ReadModelLoadGraph, ReadModelError>> + Send + '_
Source§impl<R, L> AsyncSnapshotStore for QueuedRepository<R, L>where
R: AsyncSnapshotStore,
L: AsyncLockManager,
impl<R, L> AsyncSnapshotStore for QueuedRepository<R, L>where
R: AsyncSnapshotStore,
L: AsyncLockManager,
fn get_snapshot_async<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<Option<SnapshotRecord>, RepositoryError>> + Send + 'a
fn save_snapshot_async<'a>( &'a self, identity: &'a StreamIdentity, record: SnapshotRecord, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
fn delete_snapshot_async<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<bool, RepositoryError>> + Send + 'a
Source§impl<R, L> AsyncTransactionalCommit for QueuedRepository<R, L>where
R: AsyncTransactionalCommit,
L: AsyncLockManager,
impl<R, L> AsyncTransactionalCommit for QueuedRepository<R, L>where
R: AsyncTransactionalCommit,
L: AsyncLockManager,
fn commit_batch_async<'a>( &'a self, batch: AsyncCommitBatch<'a>, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
Source§impl<R, L: AsyncLockManager> AsyncUnlockableRepository for QueuedRepository<R, L>
impl<R, L: AsyncLockManager> AsyncUnlockableRepository for QueuedRepository<R, L>
Source§fn unlock<'a>(
&'a self,
identity: &'a StreamIdentity,
) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
fn unlock<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
Release the lock held for a stream. Read more
Source§fn abort<'a>(
&'a self,
identity: &'a StreamIdentity,
) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
fn abort<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a
Release a lock for an aborted load (alias for
unlock).Auto Trait Implementations§
impl<R, L> Freeze for QueuedRepository<R, L>where
R: Freeze,
impl<R, L> RefUnwindSafe for QueuedRepository<R, L>where
R: RefUnwindSafe,
L: RefUnwindSafe,
impl<R, L> Send for QueuedRepository<R, L>
impl<R, L> Sync for QueuedRepository<R, L>
impl<R, L> Unpin for QueuedRepository<R, L>where
R: Unpin,
impl<R, L> UnsafeUnpin for QueuedRepository<R, L>where
R: UnsafeUnpin,
impl<R, L> UnwindSafe for QueuedRepository<R, L>where
R: UnwindSafe,
L: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> AsyncAggregateBuilder for T
impl<T> AsyncAggregateBuilder for T
fn async_aggregate<A: Aggregate>(self) -> AsyncAggregateRepository<Self, A>
Source§impl<R> AsyncCommitBuilderExt for Rwhere
R: AsyncTransactionalCommit,
impl<R> AsyncCommitBuilderExt for Rwhere
R: AsyncTransactionalCommit,
Source§fn outbox(&self, msg: OutboxMessage) -> AsyncCommitBuilder<'_, Self>
fn outbox(&self, msg: OutboxMessage) -> AsyncCommitBuilder<'_, Self>
Start an async commit builder chain with an outbox message.
Source§impl<S> AsyncReadModelWorkspaceExt for S
impl<S> AsyncReadModelWorkspaceExt for S
fn workspace_async(&self) -> ReadModelWorkspace<'_, Self>
Source§impl<R> AsyncReadModelWritePlanCommitExt for Rwhere
R: AsyncTransactionalCommit,
impl<R> AsyncReadModelWritePlanCommitExt for Rwhere
R: AsyncTransactionalCommit,
Source§fn read_models(
&self,
read_models: ReadModelWritePlanBuilder,
) -> AsyncCommitBuilder<'_, Self>
fn read_models( &self, read_models: ReadModelWritePlanBuilder, ) -> AsyncCommitBuilder<'_, Self>
Start an async commit builder chain with a relational read-model write plan.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> HasReadModelStore for S
impl<S> HasReadModelStore for S
type ReadModelStore = S
fn read_model_store(&self) -> &<S as HasReadModelStore>::ReadModelStore
Source§impl<R> HasRepo for Rwhere
R: AsyncRepository,
impl<R> HasRepo for Rwhere
R: AsyncRepository,
Source§impl<T> Queueable for T
impl<T> Queueable for T
Source§fn queued_async(self) -> QueuedRepository<Self, InMemoryAsyncLockManager>
fn queued_async(self) -> QueuedRepository<Self, InMemoryAsyncLockManager>
Wrap with the default async lock manager. Pair with
.async_aggregate::<T>() for per-aggregate serialization over the async
repository surface.Source§fn queued_async_with<L: AsyncLockManager>(
self,
lock_manager: L,
) -> QueuedRepository<Self, L>
fn queued_async_with<L: AsyncLockManager>( self, lock_manager: L, ) -> QueuedRepository<Self, L>
Wrap with a custom async lock manager.