vertx / io.vertx.rxjava.circuitbreaker / CircuitBreaker / executeAndReportWithFallback

executeAndReportWithFallback

open fun <T : Any> executeAndReportWithFallback(resultFuture: Future<T>, command: Handler<Future<T>>, fallback: Function<Throwable, T>): CircuitBreaker

Executes the given operation with the circuit breaker control. The operation is generally calling an external system. The operation receives a object as parameter and must call when the operation has terminated successfully. The operation must also call in case of failure.

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 io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeWithFallback, 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.

Parameters

resultFuture - the future 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

Return
the current io.vertx.rxjava.circuitbreaker.CircuitBreaker