minos.plugins.aiopg.clients
Classes
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]
- 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 orFalse
otherwise.- Return type
- 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 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
- 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
- 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 orFalse
otherwise.- Return type
- 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
base (type[minos.common.database.operations.DatabaseOperationFactory]) – The operation factory interface.
impl (type[minos.common.database.operations.DatabaseOperationFactory]) – The operation factory implementation.
- 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
- async with_circuit_breaker(fn)
Execute the given function with circuit breaker.