Class CircuitBreakerConfig.Builder
java.lang.Object
com.couchbase.client.core.endpoint.CircuitBreakerConfig.Builder
- Enclosing class:
CircuitBreakerConfig
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates a newCircuitBreakerConfig
out of the configured properties.completionCallback
(CircuitBreaker.CompletionCallback completionCallback) Allows customizing of the completion callback which defines what is considered a failure and what success.enabled
(boolean enabled) Enables or disables this circuit breaker.errorThresholdPercentage
(int errorThresholdPercentage) The percentage of operations that need to fail in a window until the circuit is opened.rollingWindow
(Duration rollingWindow) How long the window is in which the number of failed ops are tracked in a rolling fashion.sleepWindow
(Duration sleepWindow) The sleep window that is waited from when the circuit opens to when the canary is tried.volumeThreshold
(int volumeThreshold) The volume threshold defines how many operations need to be in the window at least so that the threshold percentage can be meaningfully calculated.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
enabled
Enables or disables this circuit breaker.If this property is set to false, then all other properties are not looked at.
- Parameters:
enabled
- if true enables it, if false disables it.- Returns:
- this
CircuitBreakerConfig.Builder
for chaining purposes.
-
volumeThreshold
The volume threshold defines how many operations need to be in the window at least so that the threshold percentage can be meaningfully calculated.The default is 20.
- Parameters:
volumeThreshold
- the volume threshold in the interval.- Returns:
- this
CircuitBreakerConfig.Builder
for chaining purposes.
-
errorThresholdPercentage
The percentage of operations that need to fail in a window until the circuit is opened.The default is 50.
- Parameters:
errorThresholdPercentage
- the percent of ops that need to fail.- Returns:
- this
CircuitBreakerConfig.Builder
for chaining purposes.
-
sleepWindow
The sleep window that is waited from when the circuit opens to when the canary is tried.The default is 5 seconds.
- Parameters:
sleepWindow
- the sleep window as a duration.- Returns:
- this
CircuitBreakerConfig.Builder
for chaining purposes.
-
rollingWindow
How long the window is in which the number of failed ops are tracked in a rolling fashion.The default is 1 minute.
- Parameters:
rollingWindow
- the rolling window duration.- Returns:
- this
CircuitBreakerConfig.Builder
for chaining purposes.
-
completionCallback
public CircuitBreakerConfig.Builder completionCallback(CircuitBreaker.CompletionCallback completionCallback) Allows customizing of the completion callback which defines what is considered a failure and what success.- Parameters:
completionCallback
- the custom completion callback.- Returns:
- this
CircuitBreakerConfig.Builder
for chaining purposes.
-
build
Creates a newCircuitBreakerConfig
out of the configured properties.- Returns:
- the new
CircuitBreakerConfig
.
-