2

I can see that I can programmatically set the state to force open like so using the following code: CircuitBreaker Forced Open State

But is there a way to set a property to set the state to this immediately when the application starts, so it can be used with tests?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
perkss
  • 1,037
  • 1
  • 11
  • 37

1 Answers1

4

No, at the moment there is no way to set it via a property. But it's simple in tests. Do you use any framework like Spring Boot? If you use Spring Boot, you can inject the CircuitBreakerRegistry into your test. Retrieve the CircuitBreaker instance and transition to OPEN, before running the test.

Robert Winkler
  • 1,734
  • 9
  • 8
  • That’s a shame. I am actually doing test containers test so would have been nice to have something setup so I can set a property. Will have to create my own property and then switch it off – perkss Sep 25 '19 at 16:50
  • Good answer, but would be even better with a short example of code. :) Your instructions are correct, but for a beginner they might not be descriptive enough. – Honza Zidek Oct 09 '20 at 20:10