Repository
Bases: Generic[TAggregate]
Repository for event-sourced aggregates.
Provides loading and persisting of aggregates using an event store. Handles event replay to reconstruct aggregate state and persists new events emitted by the aggregate.
Source code in event_sourcery/event_sourcing/repository.py
aggregate(uuid, aggregate)
Context manager for loading an aggregate instance.
Loads the aggregate's event stream, replays events to reconstruct its state, yields the aggregate for use, 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 state into. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
TAggregate |
TAggregate
|
The loaded and ready-to-use aggregate instance. |