pub struct AggregateRepository<R, A> { /* private fields */ }Expand description
Async repository wrapper for a specific aggregate type.
Snapshots are an optional, transparent optimization: with_snapshots(n)
configures snapshot caching on this same type, and every method behaves
identically with or without it — on commit a snapshot is staged in the same
transaction when due, and on load the aggregate is hydrated from a snapshot
when one exists.
Implementations§
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
pub async fn get(&self, id: &str) -> Result<Option<A>, RepositoryError>
Sourcepub async fn get_all(&self, ids: &[&str]) -> Result<Vec<A>, RepositoryError>
pub async fn get_all(&self, ids: &[&str]) -> Result<Vec<A>, RepositoryError>
Load existing aggregates for the provided ids.
Each id is converted to a StreamIdentity, fetched through get_streams,
and hydrated if present. Missing streams are skipped, and backend
implementations may return aggregates in storage order rather than input
order.
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
pub async fn commit(&self, aggregate: &mut A) -> Result<(), RepositoryError>
pub async fn commit_all( &self, aggregates: &mut [&mut A], ) -> Result<(), RepositoryError>
pub async fn commit_entities( &self, streams: Vec<(StreamIdentity, &mut Entity)>, ) -> Result<(), RepositoryError>
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
Sourcepub async fn get_all_with(
&self,
ids: &[&str],
opts: ReadOpts,
) -> Result<Vec<A>, RepositoryError>
pub async fn get_all_with( &self, ids: &[&str], opts: ReadOpts, ) -> Result<Vec<A>, RepositoryError>
Load aggregates for the provided ids with options.
Source§impl<R, A> AggregateRepository<R, A>where
R: UnlockableRepository,
A: Aggregate,
impl<R, A> AggregateRepository<R, A>where
R: UnlockableRepository,
A: Aggregate,
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
Sourcepub fn outbox(&self, message: OutboxMessage) -> AggregateCommit<'_, R, A>
pub fn outbox(&self, message: OutboxMessage) -> AggregateCommit<'_, R, A>
Start a commit with an outbox message attached.
Sourcepub fn read_models(
&self,
read_models: ReadModelWritePlanBuilder,
) -> AggregateCommit<'_, R, A>
pub fn read_models( &self, read_models: ReadModelWritePlanBuilder, ) -> AggregateCommit<'_, R, A>
Start a commit with relational read-model writes attached. Composes with
.outbox(..), the aggregate’s events, and snapshots in one transaction.
Source§impl<R, A> AggregateRepository<R, A>
impl<R, A> AggregateRepository<R, A>
Sourcepub fn with_snapshots(self, frequency: u64) -> Self
pub fn with_snapshots(self, frequency: u64) -> Self
Enable snapshot caching at the given event frequency.
Snapshots are a transparent optimization: this configures snapshot behaviour on the same repository type and returns it. On commit a snapshot is staged (when due) in the same transaction; on load the aggregate is hydrated from a snapshot when one exists. Every other method behaves identically with or without snapshots.
Trait Implementations§
Source§impl<R, A> ConfigurableOutboxPublisher for AggregateRepository<R, A>
impl<R, A> ConfigurableOutboxPublisher for AggregateRepository<R, A>
Source§fn configure_outbox_publisher(&mut self, config: OutboxPublisherConfig)
fn configure_outbox_publisher(&mut self, config: OutboxPublisherConfig)
Source§impl<R, A> HasOutboxStore for AggregateRepository<R, A>where
R: HasOutboxStore,
impl<R, A> HasOutboxStore for AggregateRepository<R, A>where
R: HasOutboxStore,
Source§type OutboxStore = <R as HasOutboxStore>::OutboxStore
type OutboxStore = <R as HasOutboxStore>::OutboxStore
Source§fn outbox_store(&self) -> Self::OutboxStore
fn outbox_store(&self) -> Self::OutboxStore
Auto Trait Implementations§
impl<R, A> !RefUnwindSafe for AggregateRepository<R, A>
impl<R, A> !UnwindSafe for AggregateRepository<R, A>
impl<R, A> Freeze for AggregateRepository<R, A>where
R: Freeze,
impl<R, A> Send for AggregateRepository<R, A>
impl<R, A> Sync for AggregateRepository<R, A>
impl<R, A> Unpin for AggregateRepository<R, A>
impl<R, A> UnsafeUnpin for AggregateRepository<R, A>where
R: UnsafeUnpin,
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> Queueable for T
impl<T> Queueable for T
Source§fn queued(self) -> QueuedRepository<Self, InMemoryAsyncLockManager>
fn queued(self) -> QueuedRepository<Self, InMemoryAsyncLockManager>
.aggregate::<T>() for per-aggregate serialization over the async
repository surface.