@Test void testCustomCombination() { CircuitBreaker breaker = CircuitBreaker.builder() .build(); Bulkhead bulkhead = Bulkhead.builder() .limit(1) .queueLength(0) .build(); FtHandlerTyped<String> faultTolerance = FaultTolerance.builder() .addBreaker(breaker) .addBulkhead(bulkhead) .addTimeout(Timeout.builder().timeout(Duration.ofMillis(100)).build()) .addFallback(Fallback.<String>builder() .fallback(this::fallback) .build()) .build(); Single<String> result = faultTolerance.invoke(this::primary); assertThat(result.await(1, TimeUnit.SECONDS), is(MyException.class.getName())); breaker.state(CircuitBreaker.State.OPEN); result = faultTolerance.invoke(this::primary); assertThat(result.await(1, TimeUnit.SECONDS), is(CircuitBreakerOpenException.class.getName())); breaker.state(CircuitBreaker.State.CLOSED); Manual m = new Manual(); Single<String> manualResult = bulkhead.invoke(m::call); result = faultTolerance.invoke(this::primary); assertThat(result.await(1, TimeUnit.SECONDS), is(BulkheadException.class.getName())); m.future.complete("result"); manualResult.await(1, TimeUnit.SECONDS); m = new Manual(); result = faultTolerance.invoke(m::call); assertThat(result.await(1, TimeUnit.SECONDS), is(TimeoutException.class.getName())); m.future.complete("hu"); }
public static Builder builder() { return new Builder(); }
FaultTolerance { public static Builder builder() { return new Builder(); } }
FaultTolerance { public static Builder builder() { return new Builder(); } private  FaultTolerance(); }
FaultTolerance { public static Builder builder() { return new Builder(); } private  FaultTolerance(); static void config(Config config); static void executor(Supplier<? extends ExecutorService> executor); static void scheduledExecutor(Supplier<? extends ScheduledExecutorService> executor); static Builder builder(); static TypedBuilder<T> typedBuilder(); }
FaultTolerance { public static Builder builder() { return new Builder(); } private  FaultTolerance(); static void config(Config config); static void executor(Supplier<? extends ExecutorService> executor); static void scheduledExecutor(Supplier<? extends ScheduledExecutorService> executor); static Builder builder(); static TypedBuilder<T> typedBuilder();  }