Class CircuitBreakerConfig.Builder

java.lang.Object
com.couchbase.client.core.endpoint.CircuitBreakerConfig.Builder
Enclosing class:
CircuitBreakerConfig

public static class CircuitBreakerConfig.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • 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.Builder for 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.Builder for 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.Builder for 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.Builder for 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.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

      public CircuitBreakerConfig build()
      Creates a new CircuitBreakerConfig out of the configured properties.
      Returns:
      the new CircuitBreakerConfig.