minos.aggregate.events.repositories.database.impl
Classes
Database-based implementation of the event repository class. |
- class DatabaseEventRepository[source]
Bases:
DatabaseMixin
[EventDatabaseOperationFactory
],EventRepository
Database-based implementation of the event repository class.
- async create(entry)
Store new creation entry into the repository.
- Parameters
entry (Union[Event, EventEntry]) – Entry to be stored.
- Returns
The repository entry containing the stored information.
- Return type
- property database_client_cls: type[minos.common.database.clients.abc.DatabaseClient]
Get the client’s class.
- Returns
A
type
instance that is subclass ofDatabaseClient
.
- property database_operation_factory: Optional[minos.common.database.mixins.GenericDatabaseOperationFactory]
Get the operation factory if any.
- Returns
A
OperationFactory
if it has been set orNone
otherwise.
- property database_pool: minos.common.database.pools.DatabaseClientPool
Get the database pool.
- Returns
A
DatabaseClientPool
object.
- async delete(entry)
Store new deletion entry into the repository.
- Parameters
entry (Union[Event, EventEntry]) – Entry to be stored.
- Returns
The repository entry containing the stored information.
- Return type
- async destroy()
Destroy miscellaneous repository things.
- Returns
This method does not return anything.
- Return type
None
- async execute_on_database(operation)
Submit an Operation.
- Parameters
operation (DatabaseOperation) – The operation to be executed.
- Returns
This method does not return anything.
- Return type
None
- async execute_on_database_and_fetch_all(operation, streaming_mode=None)
Submit an Operation and return an asynchronous iterator.
- Parameters
operation (DatabaseOperation) – The operation to be executed.
streaming_mode (Optional[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.
- Returns
This method does not return anything.
- Return type
- async execute_on_database_and_fetch_one(operation)
Submit an Operation and get the first response.
- Parameters
operation (DatabaseOperation) – The operation to be executed.
- Returns
This method does not return anything.
- 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
- property offset: Awaitable[int]
Get the current repository offset.
- Returns
An awaitable containing an integer value.
- async select(uuid=None, name=None, version=None, version_lt=None, version_gt=None, version_le=None, version_ge=None, id=None, id_lt=None, id_gt=None, id_le=None, id_ge=None, transaction_uuid=None, transaction_uuid_ne=None, transaction_uuid_in=None, **kwargs)
Perform a selection query of entries stored in to the repository.
- Parameters
uuid (Optional[UUID]) – The identifier must be equal to the given value.
name (Optional[Union[str, type[RootEntity]]]) – The classname must be equal to the given value.
version (Optional[int]) – The version must be equal to the given value.
version_lt (Optional[int]) – The version must be lower than the given value.
version_gt (Optional[int]) – The version must be greater than the given value.
version_le (Optional[int]) – The version must be lower or equal to the given value.
version_ge (Optional[int]) – The version must be greater or equal to the given value.
id (Optional[int]) – The entry identifier must be equal to the given value.
id_lt (Optional[int]) – The entry identifier must be lower than the given value.
id_gt (Optional[int]) – The entry identifier must be greater than the given value.
id_le (Optional[int]) – The entry identifier must be lower or equal to the given value.
id_ge (Optional[int]) – The entry identifier must be greater or equal to the given value.
transaction_uuid (Optional[UUID]) – The transaction identifier must be equal to the given value.
transaction_uuid_ne (Optional[UUID]) – The transaction identifier must be distinct of the given value.
transaction_uuid_in (Optional[tuple[UUID, ...]]) – The destination transaction identifier must be equal to one of the given values.
- Returns
A list of entries.
- Return type
AsyncIterator[EventEntry]
- async setup()
Setup miscellaneous repository things.
- Returns
This method does not return anything.
- Return type
None
- async submit(entry, **kwargs)
Store new entry into the repository.
- Parameters
entry (Union[Event, EventEntry]) – The entry to be stored.
kwargs – Additional named arguments.
- Returns
The repository entry containing the stored information.
- Return type
- transaction(**kwargs)
Build a transaction instance related to the repository.
- Parameters
kwargs – Additional named arguments.
- Returns
A new
TransactionEntry
instance.- Return type
- async update(entry)
Store new update entry into the repository.
- Parameters
entry (Union[Event, EventEntry]) – Entry to be stored.
- Returns
The repository entry containing the stored information.
- Return type
- async validate(entry, transaction_uuid_ne=None, **kwargs)
Check if it is able to submit the given entry.
- Parameters
entry (EventEntry) – The entry to be validated.
transaction_uuid_ne (Optional[UUID]) – Optional transaction identifier to skip it from the validation.
kwargs – Additional named arguments.
- Returns
True
if the entry can be submitted orFalse
otherwise.- Return type