minos.aggregate.snapshots.abc module

class minos.aggregate.snapshots.abc.SnapshotRepository(*args, already_setup=False, **kwargs)[source]

Bases: abc.ABC, minos.common.setup.MinosSetup

Base Snapshot class.

The snapshot provides a direct accessor to the aggregate instances stored as events by the event repository class.

__init__(*args, already_setup=False, **kwargs)
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)[source]

Find a collection of Aggregate instances based on a Condition.

Parameters
  • aggregate_name (str) – Class name of the Aggregate.

  • condition (minos.aggregate.queries._Condition) – The condition that must be satisfied by the Aggregate 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) – 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 (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)[source]

Get an aggregate instance from its identifier.

Parameters
  • aggregate_name (str) – Class name of the Aggregate.

  • uuid (uuid.UUID) – Identifier of the Aggregate.

  • 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

minos.aggregate.models.aggregates.Aggregate

Returns

The Aggregate instance.

async setup()

Setup miscellaneous repository things.

Return type

None

Returns

This method does not return anything.

synchronize(**kwargs)[source]

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.