Class CircuitBreaker
- All Implemented Interfaces:
MutinyDelegate
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Clement Escoffier
- See Also:
-
CircuitBreaker
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCircuitBreaker(io.vertx.circuitbreaker.CircuitBreaker delegate) Create a new instance ofCircuitBreakerdelegating to the given (non-null) instance ofCircuitBreaker.CircuitBreaker(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionclose()Closes the circuit breaker.closeHandler(Runnable handler) Sets aHandlerto be invoked when the circuit breaker state switches to closed.static CircuitBreakerCreates a new instance ofCircuitBreaker, with default options.static CircuitBreakerCreates a new instance ofCircuitBreaker.boolean<T> io.smallrye.mutiny.Uni<T>execute(io.smallrye.mutiny.Uni<T> command) Same as#executeWithFallback(Handler, Function)but using the circuit breaker default fallback.<T> io.smallrye.mutiny.Uni<T>Same asexecuteWithFallback(Supplier, Function)but using the circuit breaker default fallback.<T> TexecuteAndAwait(io.smallrye.mutiny.Uni<T> command) Same as#executeWithFallback(Handler, Function)but using the circuit breaker default fallback.<T> TexecuteAndAwait(Supplier<io.smallrye.mutiny.Uni<T>> command) Same asexecuteWithFallback(Supplier, Function)but using the circuit breaker default fallback.<T> CircuitBreakerexecuteAndForget(io.smallrye.mutiny.Uni<T> command) Same as#executeWithFallback(Handler, Function)but using the circuit breaker default fallback.<T> CircuitBreakerexecuteAndForget(Supplier<io.smallrye.mutiny.Uni<T>> command) Same asexecuteWithFallback(Supplier, Function)but using the circuit breaker default fallback.<T> CircuitBreakerexecuteAndReport(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command) Same as#executeAndReportWithFallback(Promise, Handler, Function)but using the circuit breaker default fallback.<T> CircuitBreakerexecuteAndReportWithFallback(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.<T> io.smallrye.mutiny.Uni<T>executeWithFallback(io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.<T> io.smallrye.mutiny.Uni<T>executeWithFallback(Supplier<io.smallrye.mutiny.Uni<T>> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.<T> TexecuteWithFallbackAndAwait(io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.<T> TexecuteWithFallbackAndAwait(Supplier<io.smallrye.mutiny.Uni<T>> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.<T> CircuitBreakerexecuteWithFallbackAndForget(io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.<T> CircuitBreakerexecuteWithFallbackAndForget(Supplier<io.smallrye.mutiny.Uni<T>> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control.long<T> CircuitBreakerfailurePolicy(FailurePolicy<T> failurePolicy) Configures the failure policy for this circuit-breaker.<T> CircuitBreakerSets a default fallbackFunctionto be invoked when the circuit breaker is open or when failure occurs andCircuitBreakerOptions.isFallbackOnFailure()is enabled.io.vertx.circuitbreaker.CircuitBreakerGet the delegate instance.halfOpenHandler(Runnable handler) Sets aHandlerto be invoked when the circuit breaker state switches to half-open.inthashCode()name()static CircuitBreakernewInstance(io.vertx.circuitbreaker.CircuitBreaker delegate) Creates a new instance of theCircuitBreaker.open()Explicitly opens the circuit breaker.openHandler(Runnable handler) Sets aHandlerto be invoked when the circuit breaker state switches to open.reset()Resets the circuit breaker state.retryPolicy(RetryPolicy retryPolicy) Set aRetryPolicywhich computes a delay before a retry attempt.io.vertx.circuitbreaker.CircuitBreakerStatestate()toString()
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
CircuitBreaker
public CircuitBreaker(io.vertx.circuitbreaker.CircuitBreaker delegate) Create a new instance ofCircuitBreakerdelegating to the given (non-null) instance ofCircuitBreaker. -
CircuitBreaker
-
-
Method Details
-
getDelegate
public io.vertx.circuitbreaker.CircuitBreaker getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Returns:
- the delegate instance
-
executeWithFallback
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeWithFallback(io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
This method returns a
Futureobject to retrieve the status and result of the operation, with the status being a success or a failure. If the fallback is called, the returned uni is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned uni is marked as failed.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Type Parameters:
T- the type of result- Parameters:
command- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
CircuitBreaker.executeWithFallback(Handler, Function)
-
executeWithFallbackAndAwait
public <T> T executeWithFallbackAndAwait(io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
This method returns a
Futureobject to retrieve the status and result of the operation, with the status being a success or a failure. If the fallback is called, the returned underlying uni is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned underlying uni is marked as failed.Unlike the bare Vert.x variant, this method returns a
CircuitBreaker. This method awaits indefinitely 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 aRuntimeException).- Type Parameters:
T- the type of result- Parameters:
command- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- The operation result
- See Also:
-
CircuitBreaker.executeWithFallback(Handler, Function)
-
executeWithFallbackAndForget
public <T> CircuitBreaker executeWithFallbackAndForget(io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
This method returns a
Futureobject to retrieve the status and result of the operation, with the status being a success or a failure. If the fallback is called, the returned underlying uni is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned underlying uni is marked as failed.Unlike the bare Vert.x variant, this method ignores the
CircuitBreakerresult or any failure.- Type Parameters:
T- the type of result- Parameters:
command- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- The current instance to chain operations if needed.
- See Also:
-
CircuitBreaker.executeWithFallback(Handler, Function)
-
executeWithFallback
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> executeWithFallback(Supplier<io.smallrye.mutiny.Uni<T>> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
This method returns a
Futureobject to retrieve the status and result of the operation, with the status being a success or a failure. If the fallback is called, the returned uni is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned uni is marked as failed.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Type Parameters:
T- the type of result- Parameters:
command- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
CircuitBreaker.executeWithFallback(Supplier, Function)
-
executeWithFallbackAndAwait
public <T> T executeWithFallbackAndAwait(Supplier<io.smallrye.mutiny.Uni<T>> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
This method returns a
Futureobject to retrieve the status and result of the operation, with the status being a success or a failure. If the fallback is called, the returned underlying uni is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned underlying uni is marked as failed.Unlike the bare Vert.x variant, this method returns a
CircuitBreaker. This method awaits indefinitely 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 aRuntimeException).- Type Parameters:
T- the type of result- Parameters:
command- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- The operation result
- See Also:
-
CircuitBreaker.executeWithFallback(Supplier, Function)
-
executeWithFallbackAndForget
public <T> CircuitBreaker executeWithFallbackAndForget(Supplier<io.smallrye.mutiny.Uni<T>> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
This method returns a
Futureobject to retrieve the status and result of the operation, with the status being a success or a failure. If the fallback is called, the returned underlying uni is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned underlying uni is marked as failed.Unlike the bare Vert.x variant, this method ignores the
CircuitBreakerresult or any failure.- Type Parameters:
T- the type of result- Parameters:
command- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- The current instance to chain operations if needed.
- See Also:
-
CircuitBreaker.executeWithFallback(Supplier, Function)
-
execute
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> execute(io.smallrye.mutiny.Uni<T> command) Same as#executeWithFallback(Handler, Function)but using the circuit breaker default fallback.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Type Parameters:
T- the type of result- Parameters:
command- the operation- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
CircuitBreaker.execute(Handler)
-
executeAndAwait
public <T> T executeAndAwait(io.smallrye.mutiny.Uni<T> command) Same as#executeWithFallback(Handler, Function)but using the circuit breaker default fallback.Unlike the bare Vert.x variant, this method returns a
CircuitBreaker. This method awaits indefinitely 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 aRuntimeException).- Type Parameters:
T- the type of result- Parameters:
command- the operation- Returns:
- The operation result
- See Also:
-
CircuitBreaker.execute(Handler)
-
executeAndForget
Same as#executeWithFallback(Handler, Function)but using the circuit breaker default fallback.Unlike the bare Vert.x variant, this method ignores the
CircuitBreakerresult or any failure.- Type Parameters:
T- the type of result- Parameters:
command- the operation- Returns:
- The current instance to chain operations if needed.
- See Also:
-
CircuitBreaker.execute(Handler)
-
execute
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> execute(Supplier<io.smallrye.mutiny.Uni<T>> command) Same asexecuteWithFallback(Supplier, Function)but using the circuit breaker default fallback.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Type Parameters:
T- the type of result- Parameters:
command- the operation- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
CircuitBreaker.execute(Supplier)
-
executeAndAwait
Same asexecuteWithFallback(Supplier, Function)but using the circuit breaker default fallback.Unlike the bare Vert.x variant, this method returns a
CircuitBreaker. This method awaits indefinitely 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 aRuntimeException).- Type Parameters:
T- the type of result- Parameters:
command- the operation- Returns:
- The operation result
- See Also:
-
CircuitBreaker.execute(Supplier)
-
executeAndForget
Same asexecuteWithFallback(Supplier, Function)but using the circuit breaker default fallback.Unlike the bare Vert.x variant, this method ignores the
CircuitBreakerresult or any failure.- Type Parameters:
T- the type of result- Parameters:
command- the operation- Returns:
- The current instance to chain operations if needed.
- See Also:
-
CircuitBreaker.execute(Supplier)
-
create
public static CircuitBreaker create(String name, Vertx vertx, io.vertx.circuitbreaker.CircuitBreakerOptions options) Creates a new instance ofCircuitBreaker.- Parameters:
name- the namevertx- the Vert.x instanceoptions- the configuration options- Returns:
- the created instance
-
create
Creates a new instance ofCircuitBreaker, with default options.- Parameters:
name- the namevertx- the Vert.x instance- Returns:
- the created instance
-
close
Closes the circuit breaker. It stops sending events on its state on the event bus.This method is not related to the
closedstate of the circuit breaker. To move the circuit breaker to theclosedstate, usereset(). -
openHandler
Sets aHandlerto be invoked when the circuit breaker state switches to open.- Parameters:
handler- the handler, must not benull- Returns:
- this
CircuitBreaker
-
halfOpenHandler
Sets aHandlerto be invoked when the circuit breaker state switches to half-open.- Parameters:
handler- the handler, must not benull- Returns:
- this
CircuitBreaker
-
closeHandler
Sets aHandlerto be invoked when the circuit breaker state switches to closed.- Parameters:
handler- the handler, must not benull- Returns:
- this
CircuitBreaker
-
executeAndReport
public <T> CircuitBreaker executeAndReport(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command) Same as#executeAndReportWithFallback(Promise, Handler, Function)but using the circuit breaker default fallback.- Type Parameters:
T- the type of result- Parameters:
resultPromise- the promise on which the operation result is reportedcommand- the operation- Returns:
- this
CircuitBreaker
-
executeAndReportWithFallback
public <T> CircuitBreaker executeAndReportWithFallback(Promise<T> resultPromise, io.smallrye.mutiny.Uni<T> command, Function<Throwable, T> fallback) Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives aPromiseobject as parameter and must callPromise.complete(Object)when the operation has terminated successfully. The operation must also callPromise.fail(Throwable)in case of a failure.The operation is not invoked if the circuit breaker is open, and the given fallback is called instead. The circuit breaker also monitors whether the operation completes in time. The operation is considered failed if it does not terminate before the configured timeout.
Unlike
#executeWithFallback(Handler, Function), this method does not return aFutureobject, but lets the caller pass aPromiseobject on which the result is reported. If the fallback is called, the promise is successfully completed with the value returned by the fallback function. If the fallback throws an exception, the promise is marked as failed.- Type Parameters:
T- the type of result- Parameters:
resultPromise- the promise on which the operation result is reportedcommand- the operationfallback- the fallback function; gets an exception as parameter and returns the fallback result- Returns:
- this
CircuitBreaker
-
fallback
Sets a default fallbackFunctionto be invoked when the circuit breaker is open or when failure occurs andCircuitBreakerOptions.isFallbackOnFailure()is enabled.The function gets the exception as parameter and returns the fallback result.
- Parameters:
handler- the fallback handler- Returns:
- this
CircuitBreaker
-
failurePolicy
Configures the failure policy for this circuit-breaker.- Returns:
- the current
CircuitBreaker - See Also:
-
reset
Resets the circuit breaker state. The number of recent failures is set to 0 and if the state is half-open, it is set to closed.- Returns:
- this
CircuitBreaker
-
open
Explicitly opens the circuit breaker.- Returns:
- this
CircuitBreaker
-
state
public io.vertx.circuitbreaker.CircuitBreakerState state()- Returns:
- the current state of this circuit breaker
-
failureCount
public long failureCount()- Returns:
- the current number of recorded failures
-
name
- Returns:
- the name of this circuit breaker
-
retryPolicy
Set aRetryPolicywhich computes a delay before a retry attempt. -
newInstance
Creates a new instance of theCircuitBreaker. -
hashCode
public int hashCode() -
equals
-
toString
-