Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<CircuitBreaker> |
__TYPE_ARG |
Constructor and Description |
---|
CircuitBreaker(CircuitBreaker delegate) |
CircuitBreaker(Object delegate) |
public static final io.vertx.lang.rx.TypeArg<CircuitBreaker> __TYPE_ARG
public CircuitBreaker(CircuitBreaker delegate)
public CircuitBreaker(Object delegate)
public CircuitBreaker getDelegate()
public static CircuitBreaker create(String name, Vertx vertx, CircuitBreakerOptions options)
CircuitBreaker
.name
- the namevertx
- the Vert.x instanceoptions
- the configuration optionpublic static CircuitBreaker create(String name, Vertx vertx)
CircuitBreaker
, with default options.name
- the namevertx
- the Vert.x instancepublic CircuitBreaker close()
close
state of the circuit breaker. To set the circuit breaker in the
close
state, use reset()
.public CircuitBreaker openHandler(Handler<Void> handler)
handler
- the handler, must not be null
CircuitBreaker
public CircuitBreaker halfOpenHandler(Handler<Void> handler)
handler
- the handler, must not be null
CircuitBreaker
public CircuitBreaker closeHandler(Handler<Void> handler)
handler
- the handler, must not be null
CircuitBreaker
public <T> Single<T> executeWithFallback(Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback)
executeWithFallback(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)
but using a callback.command
- the operationfallback
- the fallbackpublic <T> Single<T> rxExecuteWithFallback(Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback)
executeWithFallback(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)
but using a callback.command
- the operationfallback
- the fallbackpublic <T> Single<T> execute(Handler<Promise<T>> command)
executeWithFallback(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)
but using the circuit breaker default fallback.command
- the operationpublic <T> Single<T> rxExecute(Handler<Promise<T>> command)
executeWithFallback(io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)
but using the circuit breaker default fallback.command
- the operationpublic <T> CircuitBreaker executeAndReport(Promise<T> resultPromise, Handler<Promise<T>> command)
executeAndReportWithFallback(io.vertx.rxjava3.core.Promise<T>, io.vertx.core.Handler<io.vertx.rxjava3.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, T>)
but using the circuit breaker default
fallback.resultPromise
- the promise on which the operation result is reportedcommand
- the operationCircuitBreaker
public <T> CircuitBreaker executeAndReportWithFallback(Promise<T> resultPromise, Handler<Promise<T>> command, java.util.function.Function<Throwable,T> fallback)
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.rxjava3.core.Promise<T>>, java.util.function.Function<java.lang.Throwable, 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.
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 resultCircuitBreaker
public <T> CircuitBreaker fallback(java.util.function.Function<Throwable,T> handler)
CircuitBreakerOptions
is enabled.
The function gets the exception as parameter and returns the fallback result.
handler
- the handlerCircuitBreaker
public CircuitBreaker reset()
CircuitBreaker
public CircuitBreaker open()
CircuitBreaker
public CircuitBreakerState state()
public long failureCount()
public String name()
public CircuitBreaker retryPolicy(java.util.function.Function<Integer,Long> retryPolicy)
public static CircuitBreaker newInstance(CircuitBreaker arg)
Copyright © 2021 Eclipse. All rights reserved.