Java Code Examples for net.jodah.failsafe.CircuitBreaker#open()
The following examples show how to use
net.jodah.failsafe.CircuitBreaker#open() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenStateTest.java From failsafe with Apache License 2.0 | 5 votes |
public void testAllowsExecution() throws Throwable { // Given CircuitBreaker breaker = new CircuitBreaker().withDelay(Duration.ofMillis(100)); breaker.open(); OpenState state = new OpenState(breaker, new ClosedState(breaker, Testing.getInternals(breaker)), breaker.getDelay()); assertTrue(breaker.isOpen()); assertFalse(state.allowsExecution()); // When Thread.sleep(110); // Then assertTrue(state.allowsExecution()); assertEquals(breaker.getState(), State.HALF_OPEN); }
Example 2
Source File: ExampleRestController.java From problem-spring-web with MIT License | 5 votes |
@RequestMapping("/handler-circuit-breaker-open") public void circuitBreakerOpen() { final CircuitBreaker<Object> breaker = new CircuitBreaker<>(); breaker.open(); Failsafe.with(breaker) .run(() -> {}); }
Example 3
Source File: ExampleRestController.java From problem-spring-web with MIT License | 5 votes |
@RequestMapping("/handler-circuit-breaker-open") public void circuitBreakerOpen() { final CircuitBreaker<Object> breaker = new CircuitBreaker<>(); breaker.open(); Failsafe.with(breaker) .run(() -> {}); }