minos.common.retries

Classes

CircuitBreakerMixin

Circuit Breaker Mixin class.

class CircuitBreakerMixin[source]

Bases: Generic[E], Object

Circuit Breaker Mixin class.

__init__(circuit_breaker_error_rate=0.2, circuit_breaker_time=3, circuit_breaker_exceptions=(Exception,), **kwargs)[source]
Parameters
async with_circuit_breaker(fn)[source]

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 circuit_breaker: aiomisc.circuit_breaker.CircuitBreaker

Get the circuit breaker.

Returns

A CircuitBreaker instance.

property is_circuit_breaker_passing: bool

Check if circuit breaker is passing.

Returns

A bool instance.

property is_circuit_breaker_broken: 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.

property circuit_breaker_exceptions: tuple[type[Exception]]

Get the circuit breaker exceptions.

Returns

A tuple of Exception types.