Circuit Breaker
Using
Turns out the approach has a name: Circuit Breaker.
The gist: it temporarily blocks requests to an unreliable service until it recovers.
States:
- Closed — requests flow normally;
- Open — the breaker is "tripped", requests are rejected;
- Half-Open — probe requests to check for recovery.
Using
Here's the case: 3 forks of the same system integrated with one and the same resource. That led to write conflicts, and on top of that the resource itself would occasionally keel over. There was a temptation to use a Mutex, but there was no guarantee the forks would live on the same server.
Digging into retries, so I wouldn't have to roll my own, I found Polly. It solved both problems: on a conflict, a single retry did the trick, and after N retries we could conclude the ERP was down.
At the time I had no idea this approach had a fancy name.