Circuit Breaker¶
-
Back to Testing Overview
Return to the Testing overview page with all topics.
An open fake ICircuitBreaker leaves the primary off invocations. The fallback is on invocations. No aiobreaker extra is required.
See Request Handler Fallback and Event Handler Fallback.
breaker = OpenCircuitBreaker()
mapper.bind(
CreateOrder,
cqrs.RequestHandlerFallback(
CreateOrderHandler,
CreateOrderFallback,
circuit_breaker=breaker,
),
)
await harness.mediator.send(CreateOrder(sku="book"))
harness.invocations.assert_not_entered(CreateOrderHandler)
harness.invocations.assert_entered(CreateOrderFallback)
Library example: examples/testing/fallback.py.