io.vertx.circuitbreaker

## Class CircuitBreakerOptions

- java.lang.Object
- - io.vertx.circuitbreaker.CircuitBreakerOptions

-     public class CircuitBreakerOptions
      extends Object

  Circuit breaker configuration options. All time are given in milliseconds.
  Author:
    Clement Escoffier

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEFAULT_FALLBACK_ON_FAILURE` Default value of the fallback on failure property.
    `static int` | `DEFAULT_MAX_FAILURES` Default number of failures.
    `static int` | `DEFAULT_METRICS_ROLLING_BUCKETS` Default number of buckets used for the rolling window.
    `static long` | `DEFAULT_METRICS_ROLLING_WINDOW` Default rolling window for metrics in milliseconds.
    `static String` | `DEFAULT_NOTIFICATION_ADDRESS` Default address on which the circuit breakers are sending their update.
    `static long` | `DEFAULT_NOTIFICATION_PERIOD` Default notification period in milliseconds.
    `static long` | `DEFAULT_RESET_TIMEOUT` Default time before it attempts to re-close the circuit (half-open state) in milliseconds.
    `static long` | `DEFAULT_TIMEOUT` Default timeout in milliseconds.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CircuitBreakerOptions()` Creates a new instance of `CircuitBreakerOptions` using the default values.
    `CircuitBreakerOptions(CircuitBreakerOptions other)` Creates a new instance of `CircuitBreakerOptions` by copying the other instance.
    `CircuitBreakerOptions(JsonObject json)` Creates a new instance of `CircuitBreakerOptions` from the given json object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getFailuresRollingWindow()`
    `int` | `getMaxFailures()`
    `int` | `getMaxRetries()`
    `int` | `getMetricsRollingBuckets()`
    `long` | `getMetricsRollingWindow()`
    `String` | `getNotificationAddress()`
    `long` | `getNotificationPeriod()`
    `long` | `getResetTimeout()`
    `long` | `getTimeout()`
    `boolean` | `isFallbackOnFailure()`
    `CircuitBreakerOptions` | `setFailuresRollingWindow(long failureRollingWindow)` Sets the rolling window used for metrics.
    `CircuitBreakerOptions` | `setFallbackOnFailure(boolean fallbackOnFailure)` Sets whether or not the fallback is executed on failure, even when the circuit is closed.
    `CircuitBreakerOptions` | `setMaxFailures(int maxFailures)` Sets the maximum number of failures before opening the circuit.
    `CircuitBreakerOptions` | `setMaxRetries(int maxRetries)` Configures the number of times the circuit breaker tries to redo the operation before failing.
    `CircuitBreakerOptions` | `setMetricsRollingBuckets(int metricsRollingBuckets)` Sets the configured number of buckets the rolling window is divided into.
    `CircuitBreakerOptions` | `setMetricsRollingWindow(long metricsRollingWindow)` Sets the rolling window used for metrics.
    `CircuitBreakerOptions` | `setNotificationAddress(String notificationAddress)` Sets the event bus address on which the circuit breaker publish its state change.
    `CircuitBreakerOptions` | `setNotificationPeriod(long notificationPeriod)` Configures the period in milliseconds where the circuit breaker send a notification on the event bus with its current state.
    `CircuitBreakerOptions` | `setResetTimeout(long resetTimeout)` Sets the time in ms before it attempts to re-close the circuit (by going to the half-open state).
    `CircuitBreakerOptions` | `setTimeout(long timeoutInMs)` Sets the timeout in milliseconds.
    `JsonObject` | `toJson()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_TIMEOUT

          public static final long DEFAULT_TIMEOUT

      Default timeout in milliseconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_FAILURES

          public static final int DEFAULT_MAX_FAILURES

      Default number of failures.
      See Also:
        Constant Field Values

    - #### DEFAULT_FALLBACK_ON_FAILURE

          public static final boolean DEFAULT_FALLBACK_ON_FAILURE

      Default value of the fallback on failure property.
      See Also:
        Constant Field Values

    - #### DEFAULT_RESET_TIMEOUT

          public static final long DEFAULT_RESET_TIMEOUT

      Default time before it attempts to re-close the circuit (half-open state) in milliseconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_NOTIFICATION_ADDRESS

          public static final String DEFAULT_NOTIFICATION_ADDRESS

      Default address on which the circuit breakers are sending their update.
      See Also:
        Constant Field Values

    - #### DEFAULT_NOTIFICATION_PERIOD

          public static final long DEFAULT_NOTIFICATION_PERIOD

      Default notification period in milliseconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_METRICS_ROLLING_WINDOW

          public static final long DEFAULT_METRICS_ROLLING_WINDOW

      Default rolling window for metrics in milliseconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_METRICS_ROLLING_BUCKETS

          public static final int DEFAULT_METRICS_ROLLING_BUCKETS

      Default number of buckets used for the rolling window.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CircuitBreakerOptions

          public CircuitBreakerOptions()

      Creates a new instance of `CircuitBreakerOptions` using the default values.

    - #### CircuitBreakerOptions

          public CircuitBreakerOptions(CircuitBreakerOptions other)

      Creates a new instance of `CircuitBreakerOptions` by copying the other instance.
      Parameters:
        `other` - the instance fo copy

    - #### CircuitBreakerOptions

          public CircuitBreakerOptions(JsonObject json)

      Creates a new instance of `CircuitBreakerOptions` from the given json object.
      Parameters:
        `json` - the json object

  - ### Method Detail

    - #### toJson

          public JsonObject toJson()

      Returns:
        a json object representing the current configuration.

    - #### getMaxFailures

          public int getMaxFailures()

      Returns:
        the maximum number of failures before opening the circuit.

    - #### setMaxFailures

          public CircuitBreakerOptions setMaxFailures(int maxFailures)

      Sets the maximum number of failures before opening the circuit.
      Parameters:
        `maxFailures` - the number of failures.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getTimeout

          public long getTimeout()

      Returns:
        the configured timeout in milliseconds.

    - #### setTimeout

          public CircuitBreakerOptions setTimeout(long timeoutInMs)

      Sets the timeout in milliseconds. If an action is not completed before this timeout, the action is considered as a failure.
      Parameters:
        `timeoutInMs` - the timeout, -1 to disable the timeout
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### isFallbackOnFailure

          public boolean isFallbackOnFailure()

      Returns:
        whether or not the fallback is executed on failures, even when the circuit is closed.

    - #### setFallbackOnFailure

          public CircuitBreakerOptions setFallbackOnFailure(boolean fallbackOnFailure)

      Sets whether or not the fallback is executed on failure, even when the circuit is closed.
      Parameters:
        `fallbackOnFailure` - `true` to enable it.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getResetTimeout

          public long getResetTimeout()

      Returns:
        the time in milliseconds before it attempts to re-close the circuit (by going to the half-open state).

    - #### setResetTimeout

          public CircuitBreakerOptions setResetTimeout(long resetTimeout)

      Sets the time in ms before it attempts to re-close the circuit (by going to the half-open state). If the circuit is closed when the timeout is reached, nothing happens. `-1` disables this feature.
      Parameters:
        `resetTimeout` - the time in ms
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getNotificationAddress

          public String getNotificationAddress()

      Returns:
        the eventbus address on which the circuit breaker events are published. `null` if this feature has been disabled.

    - #### setNotificationAddress

          public CircuitBreakerOptions setNotificationAddress(String notificationAddress)

      Sets the event bus address on which the circuit breaker publish its state change.
      Parameters:
        `notificationAddress` - the address, `null` to disable this feature.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getNotificationPeriod

          public long getNotificationPeriod()

      Returns:
        the the period in milliseconds where the circuit breaker send a notification about its state.

    - #### setNotificationPeriod

          public CircuitBreakerOptions setNotificationPeriod(long notificationPeriod)

      Configures the period in milliseconds where the circuit breaker send a notification on the event bus with its current state.
      Parameters:
        `notificationPeriod` - the period, 0 to disable this feature.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getMetricsRollingWindow

          public long getMetricsRollingWindow()

      Returns:
        the configured rolling window for metrics.

    - #### setMetricsRollingWindow

          public CircuitBreakerOptions setMetricsRollingWindow(long metricsRollingWindow)

      Sets the rolling window used for metrics.
      Parameters:
        `metricsRollingWindow` - the period in milliseconds.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getFailuresRollingWindow

          public long getFailuresRollingWindow()

      Returns:
        the configured rolling window for failures.

    - #### setFailuresRollingWindow

          public CircuitBreakerOptions setFailuresRollingWindow(long failureRollingWindow)

      Sets the rolling window used for metrics.
      Parameters:
        `metricsRollingWindow` - the period in milliseconds.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getMetricsRollingBuckets

          public int getMetricsRollingBuckets()

      Returns:
        the configured number of buckets the rolling window is divided into.

    - #### setMetricsRollingBuckets

          public CircuitBreakerOptions setMetricsRollingBuckets(int metricsRollingBuckets)

      Sets the configured number of buckets the rolling window is divided into. The following must be true - metrics.rollingStats.timeInMilliseconds % metrics.rollingStats.numBuckets == 0 - otherwise it will throw an exception. In other words, 10000/10 is okay, so is 10000/20 but 10000/7 is not.
      Parameters:
        `metricsRollingBuckets` - the number of rolling buckets.
      Returns:
        the current `CircuitBreakerOptions` instance

    - #### getMaxRetries

          public int getMaxRetries()

      Returns:
        the number of times the circuit breaker tries to redo the operation before failing

    - #### setMaxRetries

          public CircuitBreakerOptions setMaxRetries(int maxRetries)

      Configures the number of times the circuit breaker tries to redo the operation before failing.
      Parameters:
        `maxRetries` - the number of retries, 0 to disable this feature.
      Returns:
        the current `CircuitBreakerOptions` instance

Copyright © 2021 Eclipse. All rights reserved.