File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
src/test/java/com/geckotechnology/simpleCircuitBreaker Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ public class DemoApp {
99
1010 private static final Random rd = new Random (System .currentTimeMillis ());
1111 private static final int NB_THREADS = 5 ;
12- private static final float ACTUAL_FAILURE_RATIO = 70 ;
12+ private static final float ACTUAL_FAILURE_RATIO_RANGE_PCT = 70 ;
13+ private static final long ACTUAL_CALL_DURATION_RANGE_MS = 1500 ;
1314 private static final long WAIT_BETWEEN_LOOP_MS = 500 ;
1415
1516 private CircuitBreaker circuitBreaker ;
@@ -53,8 +54,8 @@ public void test() {
5354 public void run () {
5455 while (true ) {
5556 if (circuitBreaker .isClosedForThisCall ()) {
56- boolean willFail = (rd .nextInt (1000 ) > 10 * ACTUAL_FAILURE_RATIO );
57- long duration = rd .nextInt (1500 );
57+ boolean willFail = (rd .nextInt (1000 ) > 10 * ACTUAL_FAILURE_RATIO_RANGE_PCT );
58+ long duration = rd .nextInt (( int ) ACTUAL_CALL_DURATION_RANGE_MS );
5859 if (willFail ) {
5960 System .out .println ("[" + threadId .get () + "] Breaker is closed. Simulating callFailed with duration: " + duration );
6061 TestUtils .sleep (duration );
You can’t perform that action at this time.
0 commit comments