Modeling the Circuit Breaker: The Shim Module
Set up the shim module of the circuit breaker and understand its usage and the way it is set up.
We'll cover the following
Getting started
For stateful properties, we’d initially began our test suite by defining generators. We then needed to refine them when it came to writing the command generation and ended up writing a shim module. This time around, we’re going to start directly with the shim module. It’s a good opportunity to revisit all kinds of possible calls that can take place.
Since we’re testing the circuit breaker itself, we’ll want to cover these situations:
- Successful calls and their effect on the internal state of the breaker.
- Calls ending in errors.
- Calls ending in errors that are whitelisted, and therefore seen as successful.
- Calls timing out.
- Manual operations to trip and untrip the circuit breaker.
Adding the dependencies
Let’s take a look at how to add the circuit_breaker
dependency. Our mix.exs
file will contain the dependencies. This is what it will look like:
Get hands-on with 1400+ tech skills courses.