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 int` | `DEFAULT_MAX_FAILURES` Default number of failures.
    `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
    --- | ---
    `int` | `getMaxFailures()`
    `String` | `getNotificationAddress()`
    `long` | `getNotificationPeriod()`
    `long` | `getResetTimeout()`
    `long` | `getTimeout()`
    `boolean` | `isFallbackOnFailure()`
    `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` | `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 hal-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

  - ### 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 hal-open state). If the cricuit 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 `CircuitBreaker` instance

Copyright © 2016. All rights reserved.