question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CircuitBreaker record a failure when a certain result is returned

See original GitHub issue

Retry allows check the result of a call and retry a call when a configurable predicate is true. It would be nice if the CircuitBreaker allows it as well. CircuitBreakerConfig should allow to configure a result predicate.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:42 (28 by maintainers)

github_iconTop GitHub Comments

2reactions
mkopyleccommented, Apr 14, 2019

Throwing exception from CB is not a good option in my case, that’s way I need global result predicate. I need CB to count some results as failures but not to throw an exception in that case. When a result predicate is configured CB should throw exception only when its state is open.

1reaction
albertllousascommented, Jun 8, 2020

My idea would be to pass the an optional result here:

https://github.com/resilience4j/resilience4j/blob/master/resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/CircuitBreaker.java#L558

Then create a function to handle it, similar as:

https://github.com/resilience4j/resilience4j/blob/master/resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/CircuitBreakerStateMachine.java#L209

For the exception I was thinking in create something like ResultRecordedAsFailureException and pass it at the end.

The change will have a lot of collateral changes, I know, but I can not see a better way to do it.

Let me create the PR, let’s see how it looks like, you can discard it, no personal attachment to the code, no worries … again is going to be huge, but we should be covered by tests

Read more comments on GitHub >

github_iconTop Results From Across the Web

Registering failed attempt inside checked function seems to ...
I'm exploring resilience4j and would like to both be able to record a failure for a circuit breaker inside a checked function, as...
Read more >
Implementing a Circuit Breaker with Resilience4j - Reflectoring
When in the open state, a circuit breaker immediately returns an error to the caller without even attempting the remote call. After some ......
Read more >
CircuitBreaker - resilience4j
The state of the CircuitBreaker changes from CLOSED to OPEN when the failure rate is equal or greater than a configurable threshold. For...
Read more >
Failover and Circuit Breaker with Resilience4j | by Rob Golder
If the number of failed calls to the primary 3PP within a given timeframe exceeds the threshold, then the circuit is opened, and...
Read more >
Resilience4j Session-5 Preventing cascading of failures in ...
Code · slidingWindowSize: Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found