minos.aggregate.snapshots.memory module¶
- class minos.aggregate.snapshots.memory.InMemorySnapshotRepository(*args, event_repository=<dependency_injector.wiring.Provide object>, transaction_repository=<dependency_injector.wiring.Provide object>, **kwargs)[source]¶
Bases:
minos.aggregate.snapshots.abc.SnapshotRepository
InMemory Snapshot class.
The snapshot provides a direct accessor to the aggregate instances stored as events by the event repository class.
- __init__(*args, event_repository=<dependency_injector.wiring.Provide object>, transaction_repository=<dependency_injector.wiring.Provide object>, **kwargs)[source]¶
- property already_destroyed: bool¶
Already Destroy getter.
- Return type
bool
- Returns
A boolean value.
- property already_setup: bool¶
Already Setup getter.
- Return type
bool
- Returns
A boolean value.
- async destroy()¶
Destroy miscellaneous repository things.
- Return type
None
- Returns
This method does not return anything.
- async find(aggregate_name, condition, ordering=None, limit=None, streaming_mode=False, transaction=None, **kwargs)¶
Find a collection of
Aggregate
instances based on aCondition
.- Parameters
aggregate_name (
str
) – Class name of theAggregate
.condition (
minos.aggregate.queries._Condition
) – The condition that must be satisfied by theAggregate
instances.ordering (
typing.Optional
[minos.aggregate.queries._Ordering
]) – Optional argument to return the instance with specific ordering strategy. The default behaviour is to retrieve them without any order pattern.limit (
typing.Optional
[int
]) – Optional argument to return only a subset of instances. The default behaviour is to return all the instances that meet the given condition.streaming_mode (
bool
) – IfTrue
return the values in streaming directly from the database (keep an open database connection), otherwise preloads the full set of values on memory and then retrieves them.transaction (
typing.Optional
[minos.aggregate.transactions.entries.TransactionEntry
]) – The transaction within the operation is performed. If not any value is provided, then the transaction is extracted from the context var. If not any transaction is being scoped then the query is performed to the global snapshot.kwargs – Additional named arguments.
- Return type
typing.AsyncIterator
[minos.aggregate.models.aggregates.Aggregate
]- Returns
An asynchronous iterator that containing the
Aggregate
instances.
- classmethod from_config(config=None, **kwargs)¶
Build a new instance from config.
- Parameters
config (
typing.Union
[minos.common.configuration.config.MinosConfig
,pathlib.Path
,None
]) – Config instance. If None is provided, default config is chosen.kwargs – Additional named arguments.
- Return type
~S
- Returns
A instance of the called class.
- async get(aggregate_name, uuid, transaction=None, **kwargs)¶
Get an aggregate instance from its identifier.
- Parameters
aggregate_name (
str
) – Class name of theAggregate
.uuid (
uuid.UUID
) – Identifier of theAggregate
.transaction (
typing.Optional
[minos.aggregate.transactions.entries.TransactionEntry
]) – The transaction within the operation is performed. If not any value is provided, then the transaction is extracted from the context var. If not any transaction is being scoped then the query is performed to the global snapshot.kwargs – Additional named arguments.
- Return type
- Returns
The
Aggregate
instance.
- async setup()¶
Setup miscellaneous repository things.
- Return type
None
- Returns
This method does not return anything.
- synchronize(**kwargs)¶
Synchronize the snapshot to the latest available version.
- Parameters
kwargs – Additional named arguments.
- Return type
typing.Awaitable
[None
]- Returns
This method does not return anything.