Class CircuitBreakerConfig.Builder
- java.lang.Object
-
- com.couchbase.client.core.endpoint.CircuitBreakerConfig.Builder
-
- Enclosing class:
- CircuitBreakerConfig
public static class CircuitBreakerConfig.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CircuitBreakerConfigbuild()Creates a newCircuitBreakerConfigout of the configured properties.CircuitBreakerConfig.BuildercompletionCallback(CircuitBreaker.CompletionCallback completionCallback)Allows customizing of the completion callback which defines what is considered a failure and what success.CircuitBreakerConfig.Builderenabled(boolean enabled)Enables or disables this circuit breaker.CircuitBreakerConfig.BuildererrorThresholdPercentage(int errorThresholdPercentage)The percentage of operations that need to fail in a window until the circuit is opened.CircuitBreakerConfig.BuilderrollingWindow(Duration rollingWindow)How long the window is in which the number of failed ops are tracked in a rolling fashion.CircuitBreakerConfig.BuildersleepWindow(Duration sleepWindow)The sleep window that is waited from when the circuit opens to when the canary is tried.CircuitBreakerConfig.BuildervolumeThreshold(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.
-
-
-
Method Detail
-
enabled
public CircuitBreakerConfig.Builder enabled(boolean 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.Builderfor chaining purposes.
-
volumeThreshold
public CircuitBreakerConfig.Builder 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.The default is 20.
- Parameters:
volumeThreshold- the volume threshold in the interval.- Returns:
- this
CircuitBreakerConfig.Builderfor chaining purposes.
-
errorThresholdPercentage
public CircuitBreakerConfig.Builder errorThresholdPercentage(int 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.Builderfor chaining purposes.
-
sleepWindow
public CircuitBreakerConfig.Builder sleepWindow(Duration 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.Builderfor chaining purposes.
-
rollingWindow
public CircuitBreakerConfig.Builder rollingWindow(Duration 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.Builderfor 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.Builderfor chaining purposes.
-
build
public CircuitBreakerConfig build()
Creates a newCircuitBreakerConfigout of the configured properties.- Returns:
- the new
CircuitBreakerConfig.
-
-