AsyncRepository
Bases: Generic[TAggregate]
Async counterpart of Repository for event-sourced aggregates.
Loads and persists aggregates using an AsyncEventStore. Event replay and
emission logic are shared with the synchronous Repository; only I/O
becomes awaitable.
Source code in event_sourcery/event_sourcing/repository_async.py
aggregate(uuid, aggregate, context=None)
async
Async context manager for loading an aggregate instance.
Loads the aggregate's event stream, replays events to reconstruct its
state, yields a WrappedAggregate containing the aggregate and
stream metadata, and persists any new events emitted during the
context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
StreamUUID
|
The unique identifier of the aggregate's stream. |
required |
aggregate
|
TAggregate
|
The aggregate initial instance to load. |
required |
context
|
Context | None
|
Optional context attached to emitted events. |
None
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[WrappedAggregate[TAggregate]]
|
WrappedAggregate[TAggregate]: The aggregate wrapped with metadata. |