/** * Sets the number of successive failures that must occur when in a closed state in order to open the circuit. * * @throws IllegalArgumentException if {@code failureThresh} < 1 */ public CircuitBreaker<R> withFailureThreshold(int failureThreshold) { Assert.isTrue(failureThreshold >= 1, "failureThreshold must be greater than or equal to 1"); return withFailureThreshold(failureThreshold, failureThreshold); }
private CircuitBreaker getCircuit(Long operationId) { CircuitBreaker breaker = circuits.get(operationId); if (Objects.isNull(breaker)) { CircuitBreaker circuitBreaker = new CircuitBreaker() .withFailureThreshold(property.getFailsafe().getFailureNumber()) .withSuccessThreshold(property.getFailsafe().getSucessNumber()) .withDelay(property.getFailsafe().getDelayTimeSeconds(), TimeUnit.SECONDS); circuits.put(operationId, circuitBreaker); breaker = circuitBreaker; } return breaker; }