vertx / io.vertx.rxjava.circuitbreaker / CircuitBreaker

CircuitBreaker

open class CircuitBreaker

An implementation of the circuit breaker pattern for Vert.x NOTE: This class has been automatically generated from the io.vertx.circuitbreaker.CircuitBreaker non RX-ified interface using Vert.x codegen.

Constructors

<init>

CircuitBreaker(delegate: CircuitBreaker)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<CircuitBreaker>

Functions

close

open fun close(): CircuitBreaker

Closes the circuit breaker. It stops sending events on its state on the event bus. This method is not related to the close state of the circuit breaker. To set the circuit breaker in the close state, use io.vertx.rxjava.circuitbreaker.CircuitBreaker#reset.

closeHandler

open fun closeHandler(handler: Handler<Void>): CircuitBreaker

Sets a invoked when the circuit breaker state switches to close.

create

open static fun create(name: String, vertx: Vertx, options: CircuitBreakerOptions): CircuitBreaker

Creates a new instance of io.vertx.rxjava.circuitbreaker.CircuitBreaker.

open static fun create(name: String, vertx: Vertx): CircuitBreaker

Creates a new instance of io.vertx.rxjava.circuitbreaker.CircuitBreaker, with default options.

equals

open fun equals(other: Any?): Boolean

execute

open fun <T : Any> execute(command: Handler<Future<T>>): Future<T>

Same as io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeWithFallback but using the circuit breaker default fallback.

executeAndReport

open fun <T : Any> executeAndReport(resultFuture: Future<T>, command: Handler<Future<T>>): CircuitBreaker

Same as io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeAndReportWithFallback but using the circuit breaker default fallback.

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.

executeCommand

open fun <T : Any> executeCommand(command: Handler<Future<T>>, handler: Handler<AsyncResult<T>>): Unit

Same as io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeWithFallback but using the circuit breaker default fallback.

executeCommandWithFallback

open fun <T : Any> executeCommandWithFallback(command: Handler<Future<T>>, fallback: Function<Throwable, T>, handler: Handler<AsyncResult<T>>): Unit

Same as io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeWithFallback but using a callback.

executeWithFallback

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

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.

This method returns a object 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 future is successfully completed with the value returned from the fallback. If the fallback throws an exception, the returned future is marked as failed.

failureCount

open fun failureCount(): Long

fallback

open fun <T : Any> fallback(handler: Function<Throwable, T>): CircuitBreaker

Sets a default invoked when the bridge is open to handle the "request", or on failure if io.vertx.circuitbreaker.CircuitBreakerOptions is enabled.

The function gets the exception as parameter and returns the fallback result.

getDelegate

open fun getDelegate(): CircuitBreaker

halfOpenHandler

open fun halfOpenHandler(handler: Handler<Void>): CircuitBreaker

Sets a invoked when the circuit breaker state switches to half-open.

hashCode

open fun hashCode(): Int

name

open fun name(): String

newInstance

open static fun newInstance(arg: CircuitBreaker): CircuitBreaker

open

open fun open(): CircuitBreaker

Explicitly opens the circuit.

openHandler

open fun openHandler(handler: Handler<Void>): CircuitBreaker

Sets a invoked when the circuit breaker state switches to open.

reset

open fun reset(): CircuitBreaker

Resets the circuit breaker state (number of failure set to 0 and state set to closed).

rxExecuteCommand

open fun <T : Any> rxExecuteCommand(command: Handler<Future<T>>): Single<T>

Same as io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeWithFallback but using the circuit breaker default fallback.

rxExecuteCommandWithFallback

open fun <T : Any> rxExecuteCommandWithFallback(command: Handler<Future<T>>, fallback: Function<Throwable, T>): Single<T>

Same as io.vertx.rxjava.circuitbreaker.CircuitBreaker#executeWithFallback but using a callback.

state

open fun state(): CircuitBreakerState

toString

open fun toString(): String