Skip to main content

QueuedRepository

Struct QueuedRepository 

Source
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>

Source

pub fn new(inner: R) -> Self

Source§

impl<R, L> QueuedRepository<R, L>

Source

pub fn inner(&self) -> &R

Access the inner repository.

Source

pub fn lock_manager(&self) -> &L

Access the lock manager.

Source§

impl<R, L: AsyncLockManager> QueuedRepository<R, L>

Source

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>

Source§

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>

Source§

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

Source§

impl<R, L> AsyncGetWithOpts for QueuedRepository<R, L>

Source§

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>

Source§

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>

Source§

impl<R, L> AsyncRelationalReadModelQueryStore for QueuedRepository<R, L>

Source§

impl<R, L> AsyncSnapshotStore for QueuedRepository<R, L>

Source§

fn get_snapshot_async<'a>( &'a self, identity: &'a StreamIdentity, ) -> impl Future<Output = Result<Option<SnapshotRecord>, RepositoryError>> + Send + 'a

Source§

fn save_snapshot_async<'a>( &'a self, identity: &'a StreamIdentity, record: SnapshotRecord, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a

Source§

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>

Source§

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>
where R: Send + Sync,

Source§

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

Release a lock for an aborted load (alias for unlock).
Source§

impl<R: Clone, L> Clone for QueuedRepository<R, L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<R, L> Freeze for QueuedRepository<R, L>
where R: Freeze,

§

impl<R, L> RefUnwindSafe for QueuedRepository<R, L>

§

impl<R, L> Send for QueuedRepository<R, L>
where R: Send, L: Sync + Send,

§

impl<R, L> Sync for QueuedRepository<R, L>
where R: Sync, L: Sync + Send,

§

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>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsyncAggregateBuilder for T

Source§

impl<R> AsyncCommitBuilderExt for R

Source§

fn outbox(&self, msg: OutboxMessage) -> AsyncCommitBuilder<'_, Self>

Start an async commit builder chain with an outbox message.
Source§

impl<S> AsyncReadModelWorkspaceExt for S

Source§

impl<R> AsyncReadModelWritePlanCommitExt for R

Source§

fn read_models( &self, read_models: ReadModelWritePlanBuilder, ) -> AsyncCommitBuilder<'_, Self>

Start an async commit builder chain with a relational read-model write plan.
Source§

fn aggregate<'a, A: Aggregate>( &'a self, aggregate: &'a mut A, ) -> AsyncStagedCommitBuilder<'a, Self>

Start a staged async commit builder with an aggregate.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> HasReadModelStore for S

Source§

impl<R> HasRepo for R
where R: AsyncRepository,

Source§

type Repo = R

Source§

fn repo(&self) -> &<R as HasRepo>::Repo

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Queueable for T

Source§

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>

Wrap with a custom async lock manager.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AsyncRepository for T