Class ResilienceConfiguration.CircuitBreakerConfiguration
java.lang.Object
com.sap.cloud.sdk.cloudplatform.resilience.ResilienceConfiguration.CircuitBreakerConfiguration
- Enclosing class:
- ResilienceConfiguration
Provides options specific to circuit breakers.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default size of the buffer in CLOSED state.static final float
The default threshold at which to transition to the OPEN state.static final int
The default size of the buffer in HALF OPEN state.static final Duration
The default duration to wait in OPEN state before transitioning into the HALF OPEN state. -
Method Summary
Modifier and TypeMethodDescriptionint
The number of latest attempts in the CLOSED state to apply the threshold to.closedBufferSize
(int closedBufferSize) The number of latest attempts in the CLOSED state to apply the threshold to.disabled()
Creates a disabledCircuitBreakerConfiguration
.boolean
float
The failure rate threshold (as percentage within [0, 100]).failureRateThreshold
(float failureRateThreshold) The failure rate threshold (as percentage within [0, 100]).int
The number of latest attempts in the HALF OPEN state to apply the threshold to.halfOpenBufferSize
(int halfOpenBufferSize) The number of latest attempts in the HALF OPEN state to apply the threshold to.int
hashCode()
boolean
Get the status indicator for the CircuitBreaker.of()
The wait duration in the OPEN state before transitioning into the HALF OPEN state.waitDuration
(Duration waitDuration) The wait duration in the OPEN state before transitioning into the HALF OPEN state.
-
Field Details
-
DEFAULT_FAILURE_RATE_THRESHOLD
public static final float DEFAULT_FAILURE_RATE_THRESHOLDThe default threshold at which to transition to the OPEN state.- See Also:
-
DEFAULT_CLOSED_BUFFER_SIZE
public static final int DEFAULT_CLOSED_BUFFER_SIZEThe default size of the buffer in CLOSED state.- See Also:
-
DEFAULT_HALF_OPEN_BUFFER_SIZE
public static final int DEFAULT_HALF_OPEN_BUFFER_SIZEThe default size of the buffer in HALF OPEN state.- See Also:
-
DEFAULT_WAIT_DURATION
The default duration to wait in OPEN state before transitioning into the HALF OPEN state.
-
-
Method Details
-
isEnabled
public boolean isEnabled()Get the status indicator for the CircuitBreaker.- Returns:
- True if the configuration is enabled.
-
disabled
Creates a disabledCircuitBreakerConfiguration
.- Returns:
- A disabled time limiter.
-
of
-
equals
-
hashCode
public int hashCode() -
failureRateThreshold
public float failureRateThreshold()The failure rate threshold (as percentage within [0, 100]). -
waitDuration
The wait duration in the OPEN state before transitioning into the HALF OPEN state. -
closedBufferSize
public int closedBufferSize()The number of latest attempts in the CLOSED state to apply the threshold to. If the failure rate over the lastclosedRingBufferSize
calls exceeds the threshold, the circuit breaker will block further calls (OPEN state). Be aware that this is the minimum number of attempts that must have occurred before the circuit breaker can take effect. -
halfOpenBufferSize
public int halfOpenBufferSize()The number of latest attempts in the HALF OPEN state to apply the threshold to. Sets the amount of attempts after which the circuit breaker will transition back to the CLOSED or OPEN state. Furthermore, this is the maximum number of requests that may take place in parallel during the HALF OPEN state. -
failureRateThreshold
@Nonnull public ResilienceConfiguration.CircuitBreakerConfiguration failureRateThreshold(float failureRateThreshold) The failure rate threshold (as percentage within [0, 100]).- Returns:
this
.
-
waitDuration
@Nonnull public ResilienceConfiguration.CircuitBreakerConfiguration waitDuration(@Nonnull Duration waitDuration) The wait duration in the OPEN state before transitioning into the HALF OPEN state.- Returns:
this
.
-
closedBufferSize
@Nonnull public ResilienceConfiguration.CircuitBreakerConfiguration closedBufferSize(int closedBufferSize) The number of latest attempts in the CLOSED state to apply the threshold to. If the failure rate over the lastclosedRingBufferSize
calls exceeds the threshold, the circuit breaker will block further calls (OPEN state). Be aware that this is the minimum number of attempts that must have occurred before the circuit breaker can take effect.- Returns:
this
.
-
halfOpenBufferSize
@Nonnull public ResilienceConfiguration.CircuitBreakerConfiguration halfOpenBufferSize(int halfOpenBufferSize) The number of latest attempts in the HALF OPEN state to apply the threshold to. Sets the amount of attempts after which the circuit breaker will transition back to the CLOSED or OPEN state. Furthermore, this is the maximum number of requests that may take place in parallel during the HALF OPEN state.- Returns:
this
.
-