minos.plugins.aiopg.clients

Classes

AiopgDatabaseClient

Aiopg Database Client class.

class AiopgDatabaseClient[source]

Bases: DatabaseClient, CircuitBreakerMixin

Aiopg Database Client class.

__init__(database, host=None, port=None, user=None, password=None, circuit_breaker_exceptions=tuple(), connection_timeout=None, cursor_timeout=None, *args, **kwargs)[source]
Parameters
async recreate()[source]

Recreate the database connection.

Returns

This method does not return anything.

Return type

None

async close()[source]

Close database connection.

Returns

This method does not return anything.

Return type

None

async is_connected()[source]

Check if the client is connected.

Returns

True if it is connected or False otherwise.

Return type

bool

property cursor: Optional[aiopg.connection.Cursor]

Get the cursor.

Returns

A Cursor instance.

property connection: Optional[aiopg.connection.Connection]

Get the connection.

Returns

A Connection instance.

property database: str

Get the database’s database.

Returns

A str value.

property host: str

Get the database’s host.

Returns

A str value.

property port: int

Get the database’s port.

Returns

An int value.

property already_destroyed: bool

Already Destroy getter.

Returns

A boolean value.

property already_setup: bool

Already Setup getter.

Returns

A boolean value.

property circuit_breaker: aiomisc.circuit_breaker.CircuitBreaker

Get the circuit breaker.

Returns

A CircuitBreaker instance.

property circuit_breaker_exceptions: tuple[type[Exception]]

Get the circuit breaker exceptions.

Returns

A tuple of Exception types.

async destroy()

Destroy miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

async execute(operation)

Execute an operation.

Parameters

operation (DatabaseOperation) – The operation to be executed.

Returns

This method does not return anything.

Return type

None

fetch_all()

Fetch all values with an asynchronous iterator.

Returns

This method does not return anything.

Return type

AsyncIterator[Any]

async fetch_one()

Fetch one value.

Returns

This method does not return anything.

Return type

Any

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

classmethod get_builder()

Get the builder class.

Returns

A Builder instance.

Return type

Builder[Ins]

classmethod get_factory(base)

Get an operation factory implementation for an operation factory interface.

Parameters

base (type[minos.common.database.operations.DatabaseOperationFactory]) – The operation factory interface.

Returns

The operation factory implementation.

Return type

DatabaseOperationFactory

property is_circuit_breaker_broken: bool

Check if circuit breaker is passing.

Returns

A bool instance.

property is_circuit_breaker_passing: bool

Check if circuit breaker is passing.

Returns

A bool instance.

property is_circuit_breaker_recovering: bool

Check if circuit breaker is passing.

Returns

A bool instance.

async is_valid(**kwargs)

Check if the instance is valid.

Returns

True if it is valid or False otherwise.

Return type

bool

property lock: Optional[DatabaseLock]

Get the lock.

Returns

A DatabaseLock instance.

async reset(**kwargs)

Reset the current instance status.

Parameters

kwargs – Additional named parameters.

Returns

This method does not return anything.

Return type

None

classmethod set_builder(builder)

Set a builder class.

Parameters

builder (Union[Builder[Ins], type[minos.common.builders.Builder[~Ins]]]) – The builder class to be set.

Returns

This method does not return anything.

Return type

None

classmethod set_factory(base, impl)

Register an operation factory implementation for an operation factory interface.

Parameters
Returns

This method does not return anything.

Return type

None

async setup()

Setup miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

property user: str

Get the database’s user.

Returns

A str value.

async with_circuit_breaker(fn)

Execute the given function with circuit breaker.

Parameters

fn (Callable[[], Union[Awaitable[R], R]]) – The function to be executed.

Returns

The return of the given function.

Return type

R

property password: str

Get the database’s password.

Returns

A str value.