io.vertx.reactivex.circuitbreaker

## Class CircuitBreaker

- java.lang.Object
- - io.vertx.reactivex.circuitbreaker.CircuitBreaker

-     public class CircuitBreaker
      extends Object

  An implementation of the circuit breaker pattern for Vert.x

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.vertx.lang.rx.TypeArg<CircuitBreaker>` | `__TYPE_ARG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CircuitBreaker(CircuitBreaker delegate)`
    `CircuitBreaker(Object delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `CircuitBreaker` | `close()` Closes the circuit breaker.
    `CircuitBreaker` | `closeHandler(Handler<Void> handler)` Sets a invoked when the circuit breaker state switches to close.
    `static CircuitBreaker` | `create(String name, Vertx vertx)` Creates a new instance of `CircuitBreaker`, with default options.
    `static CircuitBreaker` | `create(String name, Vertx vertx, CircuitBreakerOptions options)` Creates a new instance of `CircuitBreaker`.
    `boolean` | `equals(Object o)`
    `<T> void` | `execute(Handler<Promise<T>> command)` Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using the circuit breaker default fallback.
    `<T> void` | `execute(Handler<Promise<T>> command, Handler<AsyncResult<T>> handler)` Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using the circuit breaker default fallback.
    `<T> CircuitBreaker` | `executeAndReport(Promise<T> resultPromise, Handler<Promise<T>> command)` Same as `executeAndReportWithFallback(io.vertx.reactivex.core.Promise<T>, io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)` but using the circuit breaker default fallback.
    `<T> CircuitBreaker` | `executeAndReportWithFallback(Promise<T> resultPromise, Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback)` Executes the given operation with the circuit breaker control.
    `<T> void` | `executeWithFallback(Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback)` Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using a callback.
    `<T> void` | `executeWithFallback(Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback, Handler<AsyncResult<T>> handler)` Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using a callback.
    `long` | `failureCount()`
    `<T> CircuitBreaker` | `fallback(java.util.function.Function<Throwable,T> handler)` Sets a default invoked when the bridge is open to handle the "request", or on failure if `CircuitBreakerOptions` is enabled.
    `CircuitBreaker` | `getDelegate()`
    `CircuitBreaker` | `halfOpenHandler(Handler<Void> handler)` Sets a invoked when the circuit breaker state switches to half-open.
    `int` | `hashCode()`
    `String` | `name()`
    `static CircuitBreaker` | `newInstance(CircuitBreaker arg)`
    `CircuitBreaker` | `open()` Explicitly opens the circuit.
    `CircuitBreaker` | `openHandler(Handler<Void> handler)` Sets a invoked when the circuit breaker state switches to open.
    `CircuitBreaker` | `reset()` Resets the circuit breaker state (number of failure set to 0 and state set to closed).
    `CircuitBreaker` | `retryPolicy(java.util.function.Function<Integer,Long> retryPolicy)` Deprecated.
    `CircuitBreaker` | `retryPolicy(RetryPolicy retryPolicy)` Set a `RetryPolicy` which computes a delay before retry execution.
    `<T> Single<T>` | `rxExecute(Handler<Promise<T>> command)` Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using the circuit breaker default fallback.
    `<T> Single<T>` | `rxExecuteWithFallback(Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback)` Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using a callback.
    `CircuitBreakerState` | `state()`
    `String` | `toString()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<CircuitBreaker> __TYPE_ARG

  - ### Constructor Detail

    - #### CircuitBreaker

          public CircuitBreaker(CircuitBreaker delegate)

    - #### CircuitBreaker

          public CircuitBreaker(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public CircuitBreaker getDelegate()

    - #### create

          public static CircuitBreaker create(String name,
                                              Vertx vertx,
                                              CircuitBreakerOptions options)

      Creates a new instance of `CircuitBreaker`.
      Parameters:
        `name` - the name
        `vertx` - the Vert.x instance
        `options` - the configuration option
      Returns:
        the created instance

    - #### create

          public static CircuitBreaker create(String name,
                                              Vertx vertx)

      Creates a new instance of `CircuitBreaker`, with default options.
      Parameters:
        `name` - the name
        `vertx` - the Vert.x instance
      Returns:
        the created instance

    - #### close

          public CircuitBreaker close()

      Closes the circuit breaker. It stops sending events on its state on the event bus. This method is not related to the `close` state of the circuit breaker. To set the circuit breaker in the `close` state, use `reset()`.
      Returns:

    - #### openHandler

          public CircuitBreaker openHandler(Handler<Void> handler)

      Sets a invoked when the circuit breaker state switches to open.
      Parameters:
        `handler` - the handler, must not be `null`
      Returns:
        the current `CircuitBreaker`

    - #### halfOpenHandler

          public CircuitBreaker halfOpenHandler(Handler<Void> handler)

      Sets a invoked when the circuit breaker state switches to half-open.
      Parameters:
        `handler` - the handler, must not be `null`
      Returns:
        the current `CircuitBreaker`

    - #### closeHandler

          public CircuitBreaker closeHandler(Handler<Void> handler)

      Sets a invoked when the circuit breaker state switches to close.
      Parameters:
        `handler` - the handler, must not be `null`
      Returns:
        the current `CircuitBreaker`

    - #### executeWithFallback

          public <T> void executeWithFallback(Handler<Promise<T>> command,
                                              java.util.function.Function<Throwable,T> fallback,
                                              Handler<AsyncResult<T>> handler)

      Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using a callback.
      Parameters:
        `command` - the operation
        `fallback` - the fallback
        `handler` - the completion handler receiving either the operation result or the fallback result. The parameter is an because if the fallback is not called, the error is passed to the handler.

    - #### executeWithFallback

          public <T> void executeWithFallback(Handler<Promise<T>> command,
                                              java.util.function.Function<Throwable,T> fallback)

      Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using a callback.
      Parameters:
        `command` - the operation
        `fallback` - the fallback

    - #### rxExecuteWithFallback

          public <T> Single<T> rxExecuteWithFallback(Handler<Promise<T>> command,
                                                     java.util.function.Function<Throwable,T> fallback)

      Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using a callback.
      Parameters:
        `command` - the operation
        `fallback` - the fallback
      Returns:

    - #### execute

          public <T> void execute(Handler<Promise<T>> command,
                                  Handler<AsyncResult<T>> handler)

      Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using the circuit breaker default fallback.
      Parameters:
        `command` - the operation
        `handler` - the completion handler receiving either the operation result or the fallback result. The parameter is an because if the fallback is not called, the error is passed to the handler.

    - #### execute

          public <T> void execute(Handler<Promise<T>> command)

      Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using the circuit breaker default fallback.
      Parameters:
        `command` - the operation

    - #### rxExecute

          public <T> Single<T> rxExecute(Handler<Promise<T>> command)

      Same as `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` but using the circuit breaker default fallback.
      Parameters:
        `command` - the operation
      Returns:

    - #### executeAndReport

          public <T> CircuitBreaker executeAndReport(Promise<T> resultPromise,
                                                     Handler<Promise<T>> command)

      Same as `executeAndReportWithFallback(io.vertx.reactivex.core.Promise<T>, io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)` but using the circuit breaker default fallback.
      Parameters:
        `resultPromise` - the promise on which the operation result is reported
        `command` - the operation
      Returns:
        the current `CircuitBreaker`

    - #### executeAndReportWithFallback

          public <T> CircuitBreaker executeAndReportWithFallback(Promise<T> resultPromise,
                                                                 Handler<Promise<T>> command,
                                                                 java.util.function.Function<Throwable,T> fallback)

      Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives a object as parameter and must call when the operation has terminated successfully. The operation must also call in case of failure.

      The operation is not invoked if the circuit breaker is open, and the given fallback is called immediately. The circuit breaker also monitor the completion of the operation before a configure timeout. The operation is considered as failed if it does not terminate in time.

      Unlike `executeWithFallback(io.vertx.core.Handler<io.vertx.reactivex.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)`, this method does return a object, but let the caller pass a object on which the result is reported. If the fallback is called, the future is successfully completed with the value returned by the fallback function. If the fallback throws an exception, the future is marked as failed.

      Parameters:
        `resultPromise` - the promise on which the operation result is reported
        `command` - the operation
        `fallback` - the fallback function. It gets an exception as parameter and returns the fallback result
      Returns:
        the current `CircuitBreaker`

    - #### fallback

          public <T> CircuitBreaker fallback(java.util.function.Function<Throwable,T> handler)

      Sets a default invoked when the bridge is open to handle the "request", or on failure if `CircuitBreakerOptions` is enabled.

      The function gets the exception as parameter and returns the fallback result.

      Parameters:
        `handler` - the handler
      Returns:
        the current `CircuitBreaker`

    - #### reset

          public CircuitBreaker reset()

      Resets the circuit breaker state (number of failure set to 0 and state set to closed).
      Returns:
        the current `CircuitBreaker`

    - #### open

          public CircuitBreaker open()

      Explicitly opens the circuit.
      Returns:
        the current `CircuitBreaker`

    - #### state

          public CircuitBreakerState state()

      Returns:
        the current state.

    - #### failureCount

          public long failureCount()

      Returns:
        the current number of failures.

    - #### name

          public String name()

      Returns:
        the name of the circuit breaker.

    - #### retryPolicy

          @Deprecated
          public CircuitBreaker retryPolicy(java.util.function.Function<Integer,Long> retryPolicy)

      Deprecated.
      Parameters:
        `retryPolicy` -
      Returns:

    - #### retryPolicy

          public CircuitBreaker retryPolicy(RetryPolicy retryPolicy)

      Set a `RetryPolicy` which computes a delay before retry execution.
      Parameters:
        `retryPolicy` -
      Returns:

    - #### newInstance

          public static CircuitBreaker newInstance(CircuitBreaker arg)

Copyright © 2024 Eclipse. All rights reserved.