Skip to main content

QueuedRepository

Struct QueuedRepository 

Source
pub struct QueuedRepository<R, L = InMemoryLockManager> { /* 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: LockManager> QueuedRepository<R, L>

Source

pub fn with_lock_manager(inner: R, lock_manager: L) -> Self

Create a QueuedRepository with a custom async lock manager.

Trait Implementations§

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

impl<R, L> GetAllWithOpts for QueuedRepository<R, L>
where R: GetStream, L: LockManager,

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> GetStream for QueuedRepository<R, L>
where R: GetStream, L: LockManager,

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

Load the streams for the provided identities, skipping missing ones. Read more
Source§

fn get_stream_tail<'a>( &'a self, identity: &'a StreamIdentity, after_version: u64, ) -> impl Future<Output = Result<Option<Entity>, RepositoryError>> + Send + 'a

Load only the events with sequence > after_version as a tail-only Entity (see Entity::load_tail_from_history). Read more
Source§

impl<R, L> GetWithOpts for QueuedRepository<R, L>
where R: GetStream, L: LockManager,

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> HasOutboxStore for QueuedRepository<R, L>
where R: HasOutboxStore,

Source§

type OutboxStore = <R as HasOutboxStore>::OutboxStore

The concrete outbox store this repository produces.
Source§

fn outbox_store(&self) -> Self::OutboxStore

Produce a handle to the durable outbox store.
Source§

impl<R, L> InboxStore for QueuedRepository<R, L>
where R: InboxStore, L: LockManager,

Source§

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

Purge inbox receipts older than age, returning the number removed. Read more
Source§

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

Source§

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

Source§

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

Source§

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

Load the snapshots for the provided identities, skipping identities without one. Each returned record carries its own aggregate type/id, so callers can pair records back to identities. Read more
Source§

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

Source§

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

Source§

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

Source§

fn commit_batch<'a>( &'a self, batch: CommitBatch<'a>, ) -> impl Future<Output = Result<(), RepositoryError>> + Send + 'a

Source§

impl<R, L: LockManager> UnlockableRepository 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).

Auto Trait Implementations§

§

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

§

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

§

impl<R, L> Send for QueuedRepository<R, L>
where R: Send, Arc<L>: Send,

§

impl<R, L> Sync for QueuedRepository<R, L>
where R: Sync, Arc<L>: Sync,

§

impl<R, L> Unpin for QueuedRepository<R, L>
where R: Unpin, Arc<L>: Unpin,

§

impl<R, L> UnsafeUnpin for QueuedRepository<R, L>
where R: UnsafeUnpin, Arc<L>: UnsafeUnpin,

§

impl<R, L> UnwindSafe for QueuedRepository<R, L>
where R: UnwindSafe, Arc<L>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> AggregateBuilder for T

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> 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<R> CommitBuilderExt for R

Source§

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

Start an async commit builder chain with an outbox message.
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: Repository,

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(self) -> QueuedRepository<Self, InMemoryLockManager>

Wrap with the default async lock manager. Pair with .aggregate::<T>() for per-aggregate serialization over the async repository surface.
Source§

fn queued_with<L: LockManager>( self, lock_manager: L, ) -> QueuedRepository<Self, L>

Wrap with a custom async lock manager.
Source§

impl<S> ReadModelWorkspaceExt for S

Source§

fn workspace(&self) -> ReadModelWorkspace<'_, Self>

Source§

impl<R> ReadModelWritePlanCommitExt for R

Source§

fn read_models( &self, read_models: ReadModelWritePlanBuilder, ) -> CommitBuilder<'_, 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, ) -> StagedCommitBuilder<'a, Self>

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

impl<T> Repository for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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.