Class CircuitBreaker

java.lang.Object
io.vertx.mutiny.circuitbreaker.CircuitBreaker
All Implemented Interfaces:
MutinyDelegate

public class CircuitBreaker extends Object implements MutinyDelegate
An implementation of the circuit breaker pattern for Vert.x

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

  • Field Details

  • Constructor Details

    • CircuitBreaker

      public CircuitBreaker(io.vertx.circuitbreaker.CircuitBreaker delegate)
    • CircuitBreaker

      public CircuitBreaker(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.circuitbreaker.CircuitBreaker getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • 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
    • create

      public static CircuitBreaker create(String name, Vertx vertx, io.vertx.circuitbreaker.CircuitBreakerOptions options)
      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)
      Parameters:
      name - the name
      vertx - the Vert.x instance
      Returns:
      the created instance
    • close

      public CircuitBreaker close()
      Returns:
      the instance of CircuitBreaker to chain method calls.
    • openHandler

      public CircuitBreaker openHandler(Runnable handler)
      Parameters:
      handler - the handler, must not be null
      Returns:
    • halfOpenHandler

      public CircuitBreaker halfOpenHandler(Runnable handler)
      Parameters:
      handler - the handler, must not be null
      Returns:
    • closeHandler

      public CircuitBreaker closeHandler(Runnable handler)
      Parameters:
      handler - the handler, must not be null
      Returns:
    • executeWithFallback

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeWithFallback(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
      Same as executeWithFallback(io.smallrye.mutiny.Uni<T>, java.util.function.Function<java.lang.Throwable, T>) but using a callback.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      command - the operation
      fallback - the fallback
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeWithFallbackAndAwait

      public <T> T executeWithFallbackAndAwait(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
      Blocking variant of executeWithFallback(Consumer,Function).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      command - the operation
      fallback - the fallback
      Returns:
      the T instance produced by the operation.
    • executeWithFallbackAndForget

      public <T> void executeWithFallbackAndForget(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
      Variant of executeWithFallback(Consumer,Function) that ignores the result of the operation.

      This method subscribes on the result of executeWithFallback(Consumer,Function), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from executeWithFallback(Consumer,Function) but you don't need to compose it with other operations.

      Parameters:
      command - the operation
      fallback - the fallback
    • execute

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> execute(io.smallrye.mutiny.Uni<T> command)
      Same as executeWithFallback(io.smallrye.mutiny.Uni<T>, java.util.function.Function<java.lang.Throwable, T>) but using the circuit breaker default fallback.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      command - the operation
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeAndAwait

      public <T> T executeAndAwait(io.smallrye.mutiny.Uni<T> command)
      Blocking variant of execute(Consumer).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      command - the operation
      Returns:
      the T instance produced by the operation.
    • executeAndForget

      public <T> void executeAndForget(io.smallrye.mutiny.Uni<T> command)
      Variant of execute(Consumer) that ignores the result of the operation.

      This method subscribes on the result of execute(Consumer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from execute(Consumer) but you don't need to compose it with other operations.

      Parameters:
      command - the operation
    • executeAndReport

      public <T> CircuitBreaker executeAndReport(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command)
      Parameters:
      resultPromise - the promise on which the operation result is reported
      command - the operation
      Returns:
    • executeAndReportWithFallback

      public <T> CircuitBreaker executeAndReportWithFallback(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
      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(Function<Throwable,T> handler)
      Parameters:
      handler - the handler
      Returns:
      the current CircuitBreaker
    • failurePolicy

      public <T> CircuitBreaker failurePolicy(FailurePolicy<T> failurePolicy)
      Parameters:
      failurePolicy -
      Returns:
      the current CircuitBreaker
    • reset

      public CircuitBreaker reset()
      Returns:
      the current CircuitBreaker
    • open

      public CircuitBreaker open()
      Returns:
      the current CircuitBreaker
    • state

      public io.vertx.circuitbreaker.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(Function<Integer,Long> retryPolicy)
      Deprecated.
      Parameters:
      retryPolicy -
      Returns:
      the instance of CircuitBreaker to chain method calls.
    • retryPolicy

      public CircuitBreaker retryPolicy(RetryPolicy retryPolicy)
      Parameters:
      retryPolicy -
      Returns:
      the instance of CircuitBreaker to chain method calls.
    • newInstance

      public static CircuitBreaker newInstance(io.vertx.circuitbreaker.CircuitBreaker arg)