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) intfailureExecutionThreshold(package private) intfailureRateThreshold(package private) intfailureThreshold(package private) intfailureThresholdingCapacity(package private) java.time.DurationfailureThresholdingPeriod(package private) EventListener<CircuitBreakerStateChangedEvent>halfOpenListener(package private) EventListener<CircuitBreakerStateChangedEvent>openListener(package private) intsuccessThreshold(package private) intsuccessThresholdingCapacity-
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.DurationgetDelay()Returns the delay before allowing another execution on the circuit.intgetFailureExecutionThreshold()Used with time based thresholding.intgetFailureRateThreshold()Used with time based thresholding.intgetFailureThreshold()Gets the number of failures that must occur within thefailure thresholding capacitywhen in a CLOSED or HALF_OPEN state in order to open the circuit.intgetFailureThresholdingCapacity()Returns the rolling capacity for storing execution results when performing failure thresholding in the CLOSED or HALF_OPEN states.java.time.DurationgetFailureThresholdingPeriod()Used with time based thresholding.EventListener<CircuitBreakerStateChangedEvent>getHalfOpenListener()Returns the half-open event listener.EventListener<CircuitBreakerStateChangedEvent>getOpenListener()Returns the open event listener.intgetSuccessThreshold()Gets the number of successes that must occur within thesuccess thresholding capacitywhen in a HALF_OPEN state in order to open the circuit.intgetSuccessThresholdingCapacity()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:
getDelayin classDelayablePolicyConfig<R>- See Also:
CircuitBreakerBuilder.withDelay(Duration),CircuitBreaker.getRemainingDelay()
-
getFailureThreshold
public int getFailureThreshold()
Gets the number of failures that must occur within thefailure thresholding capacitywhen in a CLOSED or HALF_OPEN state in order to open the circuit. Returns1by default.
-
getFailureThresholdingCapacity
public int getFailureThresholdingCapacity()
Returns the rolling capacity for storing execution results when performing failure thresholding in the CLOSED or HALF_OPEN states.1by 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, else0if 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, elsenullif 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 thresholdingthis also determines the minimum number of executions that must be recorded in the HALF_OPEN state. Returns0by default.
-
getSuccessThreshold
public int getSuccessThreshold()
Gets the number of successes that must occur within thesuccess thresholding capacitywhen in a HALF_OPEN state in order to open the circuit. Returns0by default, in which case thefailure thresholdis 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.
-
-