minos.aggregate.snapshots.repositories.memory
Classes
InMemory Snapshot class. |
- class InMemorySnapshotRepository[source]
Bases:
SnapshotRepository
InMemory Snapshot class.
The snapshot provides a direct accessor to the
RootEntity
instances stored as events by the event repository class.- __init__(*args, event_repository, transaction_repository, **kwargs)[source]
- Parameters
event_repository (EventRepository) –
transaction_repository (TransactionRepository) –
- async destroy()
Destroy miscellaneous repository things.
- Returns
This method does not return anything.
- Return type
None
- async find(name, condition, ordering=None, limit=None, streaming_mode=False, transaction=None, **kwargs)
Find a collection of
RootEntity
instances based on aCondition
.- Parameters
name (Union[str, type[RootEntity]]) – Class name of the
RootEntity
.condition (_Condition) – The condition that must be satisfied by the
RootEntity
instances.ordering (Optional[_Ordering]) – Optional argument to return the instance with specific ordering strategy. The default behaviour is to retrieve them without any order pattern.
limit (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) – If
True
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 (Optional[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.
- Returns
An asynchronous iterator that containing the
RootEntity
instances.- Return type
AsyncIterator[RootEntity]
- async find_entries(name, condition, ordering=None, limit=None, streaming_mode=False, transaction=None, exclude_deleted=True, synchronize=True, **kwargs)
Find a collection of
SnapshotEntry
instances based on aCondition
.- Parameters
name (str) – Class name of the
RootEntity
.condition (_Condition) – The condition that must be satisfied by the
RootEntity
instances.ordering (Optional[_Ordering]) – Optional argument to return the instance with specific ordering strategy. The default behaviour is to retrieve them without any order pattern.
limit (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) – If
True
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 (Optional[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.
exclude_deleted (bool) – If
True
, deletedRootEntity
entries are included, otherwise deletedRootEntity
entries are filtered.synchronize (bool) – If
True
a synchronization is performed before processing the query, otherwise the query is performed without any synchronization step.kwargs – Additional named arguments.
- Returns
An asynchronous iterator that containing the
RootEntity
instances.- Return type
- classmethod from_config(config=None, **kwargs)
Build a new instance from config.
- Parameters
config (Optional[Union[Config, Path]]) – Config instance. If None is provided, default config is chosen.
kwargs – Additional named arguments.
- Returns
A instance of the called class.
- Return type
S
- async get(name, uuid, transaction=None, **kwargs)
Get a
RootEntity
instance from its identifier.- Parameters
name (Union[str, type[RootEntity]]) – Class name of the
RootEntity
.uuid (UUID) – Identifier of the
RootEntity
.transaction (Optional[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.
- Returns
The
RootEntity
instance.- Return type
- get_all(name, ordering=None, limit=None, streaming_mode=False, transaction=None, **kwargs)
Get all
RootEntity
instances.- Parameters
name (str) – Class name of the
RootEntity
.ordering (Optional[_Ordering]) – Optional argument to return the instance with specific ordering strategy. The default behaviour is to retrieve them without any order pattern.
limit (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) – If
True
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 (Optional[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.
- Returns
An asynchronous iterator that containing the
RootEntity
instances.- Return type
AsyncIterator[RootEntity]
- async get_entry(name, uuid, **kwargs)
Get a
SnapshotEntry
from its identifier.- Parameters
- Returns
The
SnapshotEntry
instance.- Return type
- async setup()
Setup miscellaneous repository things.
- Returns
This method does not return anything.
- Return type
None