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.

Circuit breaker: evaluate response as a failure

See original GitHub issue

Hi,

I was checking the options for Circuit Breaker: https://resilience4j.readme.io/docs/circuitbreaker

But I didn´t see the possibility to evaluate a successful response as a failure. This possibility is available for another behaviour Retry: https://resilience4j.readme.io/docs/retry

retryOnResultPredicate
result -> false
Configures a Predicate which evaluates if a result should be retried. The Predicate must return true, if the result should be retried, otherwise it must return false.

Do you think that it is possible to add something similar in this behaviour?

Many thanks in advance.

Juan Antonio

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
RobWincommented, Aug 26, 2019

We created a SupplierUtils which helps you in situations where you can’t modify the client code.

Supplier<HttpResponse> supplier = () -> httpClient.doRemoteCall();
Supplier<HttpResponse> supplierWithResultHandling = SupplierUtils.andThen(supplier, result -> {
    if (result.getStatusCode() == 400) {
       throw new HttpClientServerException();
    } else if (result.getStatusCode() == 500) {
       throw new HttpServerException();
    }
    return result;
});
HttpResponse httpResponse = circuitBreaker
  .executeSupplier(supplierWithResultHandling);
1reaction
jabrenacommented, Aug 31, 2019

Applied the solution and the usage is easy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circuit breaker performance data & field failure reports
Circuit breaker performance data & field failure reports. This document demonstrates detection and fire risks of a bad electrical circuit breaker which burned, ......
Read more >
Circuit Breaker Pattern: Make Your Apps Ready to Deal with ...
A circuit breaker pattern detects failures and prevents them from constantly recurring, protecting your servers from exhaustion and your ...
Read more >
Testing Breaker Failure Schemes
D) Circuit Breaker Alarm Breaker Failure (BGMA) Test Procedure . ... The evaluation should be changed to expect No Operation. ... I use...
Read more >
Response for Interpretation of TPL-003 and TPL-004 for SPCS
assessment of a protection system failure includes evaluation of shared or ... fault clearing time may be longer than the breaker failure ...
Read more >
Circuit Breaker | Java Design Patterns
Circuit breaker is a design pattern used in modern software development. It is used to detect failures and encapsulates the logic of preventing...
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