Class CircuitBreaker
- java.lang.Object
-
- io.vertx.mutiny.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 theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<CircuitBreaker>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description CircuitBreaker(io.vertx.circuitbreaker.CircuitBreaker delegate)
CircuitBreaker(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CircuitBreaker
close()
CircuitBreaker
closeHandler(Runnable handler)
static CircuitBreaker
create(String name, Vertx vertx)
static CircuitBreaker
create(String name, Vertx vertx, io.vertx.circuitbreaker.CircuitBreakerOptions options)
boolean
equals(Object o)
<T> io.smallrye.mutiny.Uni<T>
execute(io.smallrye.mutiny.Uni<T> command)
Same asexecuteWithFallback(io.smallrye.mutiny.Uni<T>, java.util.function.Function<java.lang.Throwable, T>)
but using the circuit breaker default fallback.<T> T
executeAndAwait(io.smallrye.mutiny.Uni<T> command)
Blocking variant ofio.vertx.mutiny.circuitbreaker.CircuitBreaker#execute(Consumer
.>) <T> void
executeAndForget(io.smallrye.mutiny.Uni<T> command)
Variant ofio.vertx.mutiny.circuitbreaker.CircuitBreaker#execute(Consumer
that ignores the result of the operation.>) <T> CircuitBreaker
executeAndReport(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command)
<T> CircuitBreaker
executeAndReportWithFallback(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
<T> io.smallrye.mutiny.Uni<T>
executeWithFallback(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
Same asexecuteWithFallback(io.smallrye.mutiny.Uni<T>, java.util.function.Function<java.lang.Throwable, T>)
but using a callback.<T> T
executeWithFallbackAndAwait(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
Blocking variant ofio.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer
.>,Function ) <T> void
executeWithFallbackAndForget(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
Variant ofio.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer
that ignores the result of the operation.>,Function ) long
failureCount()
<T> CircuitBreaker
fallback(Function<Throwable,T> handler)
io.vertx.circuitbreaker.CircuitBreaker
getDelegate()
CircuitBreaker
halfOpenHandler(Runnable handler)
int
hashCode()
String
name()
static CircuitBreaker
newInstance(io.vertx.circuitbreaker.CircuitBreaker arg)
CircuitBreaker
open()
CircuitBreaker
openHandler(Runnable handler)
CircuitBreaker
reset()
CircuitBreaker
retryPolicy(Function<Integer,Long> retryPolicy)
io.vertx.circuitbreaker.CircuitBreakerState
state()
String
toString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<CircuitBreaker> __TYPE_ARG
-
-
Constructor Detail
-
CircuitBreaker
public CircuitBreaker(io.vertx.circuitbreaker.CircuitBreaker delegate)
-
CircuitBreaker
public CircuitBreaker(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.circuitbreaker.CircuitBreaker getDelegate()
-
create
public static CircuitBreaker create(String name, Vertx vertx, io.vertx.circuitbreaker.CircuitBreakerOptions options)
- Parameters:
name
- the namevertx
- the Vert.x instanceoptions
- the configuration option- Returns:
- the created instance
-
create
public static CircuitBreaker create(String name, Vertx vertx)
- Parameters:
name
- the namevertx
- 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 benull
- Returns:
-
halfOpenHandler
public CircuitBreaker halfOpenHandler(Runnable handler)
- Parameters:
handler
- the handler, must not benull
- Returns:
-
closeHandler
public CircuitBreaker closeHandler(Runnable handler)
- Parameters:
handler
- the handler, must not benull
- Returns:
-
executeWithFallback
public <T> io.smallrye.mutiny.Uni<T> executeWithFallback(io.smallrye.mutiny.Uni<T> command, Function<Throwable,T> fallback)
Same asexecuteWithFallback(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 operationfallback
- 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 ofio.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 operationfallback
- 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 ofio.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer
that ignores the result of the operation.>,Function ) This method subscribes on the result of
io.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from>,Function ) io.vertx.mutiny.circuitbreaker.CircuitBreaker#executeWithFallback(Consumer
but you don't need to compose it with other operations.>,Function ) - Parameters:
command
- the operationfallback
- the fallback
-
execute
public <T> io.smallrye.mutiny.Uni<T> execute(io.smallrye.mutiny.Uni<T> command)
Same asexecuteWithFallback(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 ofio.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 ofio.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 reportedcommand
- 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 reportedcommand
- the operationfallback
- 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
-
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
public CircuitBreaker retryPolicy(Function<Integer,Long> retryPolicy)
-
newInstance
public static CircuitBreaker newInstance(io.vertx.circuitbreaker.CircuitBreaker arg)
-
-