Package dev.failsafe
Class CircuitBreakerConfig<R>
- java.lang.Object
-
- dev.failsafe.PolicyConfig<R>
-
- dev.failsafe.FailurePolicyConfig<R>
-
- dev.failsafe.DelayablePolicyConfig<R>
-
- dev.failsafe.CircuitBreakerConfig<R>
-
- Type Parameters:
R
- result type
public class CircuitBreakerConfig<R> extends DelayablePolicyConfig<R>
Configuration for aCircuitBreaker
.This class is threadsafe.
- See Also:
CircuitBreakerBuilder
-
-
Field Summary
Fields Modifier and Type Field Description (package private) EventListener<CircuitBreakerStateChangedEvent>
closeListener
(package private) int
failureExecutionThreshold
(package private) int
failureRateThreshold
(package private) int
failureThreshold
(package private) int
failureThresholdingCapacity
(package private) java.time.Duration
failureThresholdingPeriod
(package private) EventListener<CircuitBreakerStateChangedEvent>
halfOpenListener
(package private) EventListener<CircuitBreakerStateChangedEvent>
openListener
(package private) int
successThreshold
(package private) int
successThresholdingCapacity
-
Fields inherited from class dev.failsafe.DelayablePolicyConfig
delay, delayException, delayFn, delayResult
-
Fields inherited from class dev.failsafe.FailurePolicyConfig
exceptionsChecked, failureConditions
-
Fields inherited from class dev.failsafe.PolicyConfig
failureListener, successListener
-
-
Constructor Summary
Constructors Constructor Description CircuitBreakerConfig()
CircuitBreakerConfig(CircuitBreakerConfig<R> config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventListener<CircuitBreakerStateChangedEvent>
getCloseListener()
Returns the close event listener.java.time.Duration
getDelay()
Returns the delay before allowing another execution on the circuit.int
getFailureExecutionThreshold()
Used with time based thresholding.int
getFailureRateThreshold()
Used with time based thresholding.int
getFailureThreshold()
Gets the number of failures that must occur within thefailure thresholding capacity
when in a CLOSED or HALF_OPEN state in order to open the circuit.int
getFailureThresholdingCapacity()
Returns the rolling capacity for storing execution results when performing failure thresholding in the CLOSED or HALF_OPEN states.java.time.Duration
getFailureThresholdingPeriod()
Used with time based thresholding.EventListener<CircuitBreakerStateChangedEvent>
getHalfOpenListener()
Returns the half-open event listener.EventListener<CircuitBreakerStateChangedEvent>
getOpenListener()
Returns the open event listener.int
getSuccessThreshold()
Gets the number of successes that must occur within thesuccess thresholding capacity
when in a HALF_OPEN state in order to open the circuit.int
getSuccessThresholdingCapacity()
Returns the rolling capacity for storing execution results when performing success thresholding in the HALF_OPEN state.-
Methods inherited from class dev.failsafe.DelayablePolicyConfig
getDelayException, getDelayFn, getDelayResult
-
Methods inherited from class dev.failsafe.FailurePolicyConfig
getFailureConditions, isExceptionsChecked
-
Methods inherited from class dev.failsafe.PolicyConfig
getFailureListener, getSuccessListener
-
-
-
-
Field Detail
-
failureThreshold
int failureThreshold
-
failureRateThreshold
int failureRateThreshold
-
failureThresholdingCapacity
int failureThresholdingCapacity
-
failureExecutionThreshold
int failureExecutionThreshold
-
failureThresholdingPeriod
java.time.Duration failureThresholdingPeriod
-
successThreshold
int successThreshold
-
successThresholdingCapacity
int successThresholdingCapacity
-
openListener
EventListener<CircuitBreakerStateChangedEvent> openListener
-
halfOpenListener
EventListener<CircuitBreakerStateChangedEvent> halfOpenListener
-
closeListener
EventListener<CircuitBreakerStateChangedEvent> closeListener
-
-
Constructor Detail
-
CircuitBreakerConfig
CircuitBreakerConfig()
-
CircuitBreakerConfig
CircuitBreakerConfig(CircuitBreakerConfig<R> config)
-
-
Method Detail
-
getDelay
public java.time.Duration getDelay()
Returns the delay before allowing another execution on the circuit. Defaults to 1 minute.- Overrides:
getDelay
in classDelayablePolicyConfig<R>
- See Also:
CircuitBreakerBuilder.withDelay(Duration)
,CircuitBreaker.getRemainingDelay()
-
getFailureThreshold
public int getFailureThreshold()
Gets the number of failures that must occur within thefailure thresholding capacity
when in a CLOSED or HALF_OPEN state in order to open the circuit. Returns1
by default.
-
getFailureThresholdingCapacity
public int getFailureThresholdingCapacity()
Returns the rolling capacity for storing execution results when performing failure thresholding in the CLOSED or HALF_OPEN states.1
by default. Only the most recent executions that fit within this capacity contribute to thresholding decisions.
-
getFailureRateThreshold
public int getFailureRateThreshold()
Used with time based thresholding. Returns percentage rate of failures, from 1 to 100, that must occur when in a CLOSED or HALF_OPEN state in order to open the circuit, else0
if failure rate thresholding is not configured.
-
getFailureThresholdingPeriod
public java.time.Duration getFailureThresholdingPeriod()
Used with time based thresholding. Returns the rolling time period during which failure thresholding is performed when in the CLOSED state, elsenull
if time based failure thresholding is not configured. Only the most recent executions that occurred within this rolling time period contribute to thresholding decisions.
-
getFailureExecutionThreshold
public int getFailureExecutionThreshold()
Used with time based thresholding. Returns the minimum number of executions that must be recorded in the CLOSED state before the breaker can be opened. Forfailure rate thresholding
this also determines the minimum number of executions that must be recorded in the HALF_OPEN state. Returns0
by default.
-
getSuccessThreshold
public int getSuccessThreshold()
Gets the number of successes that must occur within thesuccess thresholding capacity
when in a HALF_OPEN state in order to open the circuit. Returns0
by default, in which case thefailure threshold
is used instead.
-
getSuccessThresholdingCapacity
public int getSuccessThresholdingCapacity()
Returns the rolling capacity for storing execution results when performing success thresholding in the HALF_OPEN state. Only the most recent executions that fit within this capacity contribute to thresholding decisions.
-
getOpenListener
public EventListener<CircuitBreakerStateChangedEvent> getOpenListener()
Returns the open event listener.
-
getHalfOpenListener
public EventListener<CircuitBreakerStateChangedEvent> getHalfOpenListener()
Returns the half-open event listener.
-
getCloseListener
public EventListener<CircuitBreakerStateChangedEvent> getCloseListener()
Returns the close event listener.
-
-