Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,18 @@ public static final class CircuitBreakerConfiguration
*/
public static final Duration DEFAULT_WAIT_DURATION = Duration.ofSeconds(10);

/**
* The default duration threshold above which calls are considered as slow.
* Matches the Resilience4j default of 60 seconds.
*/
public static final Duration DEFAULT_SLOW_CALL_DURATION_THRESHOLD = Duration.ofSeconds(60);

/**
* The default slow call rate threshold (as percentage within [0, 100]).
* Matches the Resilience4j default of 100%.
*/
public static final float DEFAULT_SLOW_CALL_RATE_THRESHOLD = 100;

/**
* Flag to indicate active CircuitBreakerConfiguration.
*/
Expand Down Expand Up @@ -461,6 +473,22 @@ public static final class CircuitBreakerConfiguration
*/
private int halfOpenBufferSize = DEFAULT_HALF_OPEN_BUFFER_SIZE;

/**
* The duration threshold above which calls are considered as slow and increase the slow call rate.
* When the percentage of slow calls is equal to or greater than {@link #slowCallRateThreshold},
* the CircuitBreaker transitions to <i>OPEN</i> and starts short-circuiting calls.
*/
@Nonnull
private Duration slowCallDurationThreshold = DEFAULT_SLOW_CALL_DURATION_THRESHOLD;

/**
* The slow call rate threshold (as percentage within [0, 100]). The CircuitBreaker considers a call as slow
* when the call duration is greater than {@link #slowCallDurationThreshold}. When the percentage of slow calls
* is equal to or greater than the threshold, the CircuitBreaker transitions to <i>OPEN</i> and starts
* short-circuiting calls.
*/
private float slowCallRateThreshold = DEFAULT_SLOW_CALL_RATE_THRESHOLD;

/**
* Get the status indicator for the CircuitBreaker.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public CircuitBreaker getCircuitBreaker( @Nonnull final ResilienceConfiguration
.slidingWindowSize(configuration.circuitBreakerConfiguration().closedBufferSize())
.minimumNumberOfCalls(configuration.circuitBreakerConfiguration().closedBufferSize())
.permittedNumberOfCallsInHalfOpenState(configuration.circuitBreakerConfiguration().halfOpenBufferSize())
.slowCallDurationThreshold(configuration.circuitBreakerConfiguration().slowCallDurationThreshold())
.slowCallRateThreshold(configuration.circuitBreakerConfiguration().slowCallRateThreshold())
.build();

val circuitBreaker = circuitBreakerRegistry.circuitBreaker(identifier, customCircuitBreakerConfig);
Expand Down
Loading