/** * Sets the number of successive successful executions that must occur when in a half-open state in order to close the * circuit, else the circuit is re-opened when a failure occurs. * * @throws IllegalArgumentException if {@code successThreshold} < 1 */ public CircuitBreaker<R> withSuccessThreshold(int successThreshold) { Assert.isTrue(successThreshold >= 1, "successThreshold must be greater than or equal to 1"); return withSuccessThreshold(successThreshold, successThreshold); }
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; }