Class 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 Mutiny-ified interface using Vert.x codegen.

    • Constructor Detail

      • CircuitBreaker

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

        public CircuitBreaker​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.circuitbreaker.CircuitBreaker getDelegate()
      • 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 io.vertx.mutiny.circuitbreaker.CircuitBreaker#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 io.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer,Function) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer,Function), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.circuitbreaker.CircuitBreaker#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 io.vertx.mutiny.circuitbreaker.CircuitBreaker#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 io.vertx.mutiny.circuitbreaker.CircuitBreaker#execute(Consumer) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.circuitbreaker.CircuitBreaker#execute(Consumer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.circuitbreaker.CircuitBreaker#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
      • 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

        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)