@Test public void testWithRetryUntilElapsed() { RetryPolicy retryPolicy = new RetryUntilElapsed(10000, 10000); CircuitBreaker circuitBreaker = new CircuitBreaker(retryPolicy, service); Assert.assertTrue(circuitBreaker.tryToOpen(() -> {})); Assert.assertEquals(lastDelay[0], Duration.ofMillis(10000)); }
boolean tryToOpen(Runnable completion) { if ( isOpen ) { return false; } isOpen = true; retryCount = 0; startNanos = System.nanoTime(); if ( tryToRetry(completion) ) { return true; } close(); return false; }
CircuitBreaker { boolean tryToOpen(Runnable completion) { if ( isOpen ) { return false; } isOpen = true; retryCount = 0; startNanos = System.nanoTime(); if ( tryToRetry(completion) ) { return true; } close(); return false; } }
CircuitBreaker { boolean tryToOpen(Runnable completion) { if ( isOpen ) { return false; } isOpen = true; retryCount = 0; startNanos = System.nanoTime(); if ( tryToRetry(completion) ) { return true; } close(); return false; } CircuitBreaker(RetryPolicy retryPolicy, ScheduledExecutorService service); }
CircuitBreaker { boolean tryToOpen(Runnable completion) { if ( isOpen ) { return false; } isOpen = true; retryCount = 0; startNanos = System.nanoTime(); if ( tryToRetry(completion) ) { return true; } close(); return false; } CircuitBreaker(RetryPolicy retryPolicy, ScheduledExecutorService service);  }
CircuitBreaker { boolean tryToOpen(Runnable completion) { if ( isOpen ) { return false; } isOpen = true; retryCount = 0; startNanos = System.nanoTime(); if ( tryToRetry(completion) ) { return true; } close(); return false; } CircuitBreaker(RetryPolicy retryPolicy, ScheduledExecutorService service);   }