CircuitBreaker

An implementation of the circuit breaker pattern for Vert.x

package

Default

Methods

__construct

__construct() 

Closes the circuit breaker. It stops sending events on its state on the event bus.

close() : $this

This method is not related to the close state of the circuit breaker. To set the circuit breaker in the close state, use @see \io\vertx\jphp\circuitbreaker\CircuitBreaker::reset.

Response

$this

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

closeHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

the current {@link CircuitBreaker}

Creates a new instance of @see \io\vertx\jphp\circuitbreaker\CircuitBreaker, with default options.

create( $arg0,  $arg1,  $arg2 = null) : \io\vertx\jphp\circuitbreaker\CircuitBreaker
static

param $name [string] the name param $vertx [Vertx] the Vert.x instance create($name, $vertx)

Creates a new instance of @see \io\vertx\jphp\circuitbreaker\CircuitBreaker.

param $name [string] the name param $vertx [Vertx] the Vert.x instance param $options [CircuitBreakerOptions | array] the configuration option create($name, $vertx, $options)

Arguments

$arg0

string

$arg1

Vertx

$arg2

array | CircuitBreakerOptions

Response

\io\vertx\jphp\circuitbreaker\CircuitBreaker

the created instance

Same as @see \io\vertx\jphp\circuitbreaker\CircuitBreaker::executeWithFallback but using the circuit breaker default fallback.

execute( $arg0) : \io\vertx\jphp\circuitbreaker\Future<T>

Arguments

$arg0

callable

Response

\io\vertx\jphp\circuitbreaker\Future

a future object completed when the operation or its fallback completes

Same as @see \io\vertx\jphp\circuitbreaker\CircuitBreaker::executeAndReportWithFallback but using the circuit breaker default fallback.

executeAndReport( $arg0,  $arg1) : $this

Arguments

$arg0

Future

$arg1

callable

Response

$this

the current {@link CircuitBreaker}

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

executeAndReportWithFallback( $arg0,  $arg1,  $arg2) : $this

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 @see \io\vertx\jphp\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.

Arguments

$arg0

Future

$arg1

callable

$arg2

callable

Response

$this

the current {@link CircuitBreaker}

Same as @see \io\vertx\jphp\circuitbreaker\CircuitBreaker::executeWithFallback but using the circuit breaker default fallback.

executeCommand( $arg0,  $arg1) : void

Arguments

$arg0

callable

$arg1

callable

Same as @see \io\vertx\jphp\circuitbreaker\CircuitBreaker::executeWithFallback but using a callback.

executeCommandWithFallback( $arg0,  $arg1,  $arg2) : void

Arguments

$arg0

callable

$arg1

callable

$arg2

callable

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

executeWithFallback( $arg0,  $arg1) : \io\vertx\jphp\circuitbreaker\Future<T>

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.

Arguments

$arg0

callable

$arg1

callable

Response

\io\vertx\jphp\circuitbreaker\Future

a future object completed when the operation or its fallback completes

failureCount

failureCount() : integer

Response

integer

the current number of failures.

Sets a <em>default</em> invoked when the bridge is open to handle the "request", or on failure if @see \io\vertx\jphp\circuitbreaker\CircuitBreakerOptions is enabled.

fallback( $arg0) : $this

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

Arguments

$arg0

callable

Response

$this

the current {@link CircuitBreaker}

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

halfOpenHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

the current {@link CircuitBreaker}

name

name() : string

Response

string

the name of the circuit breaker.

Explicitly opens the circuit.

open() : $this

Response

$this

the current {@link CircuitBreaker}

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

openHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

the current {@link CircuitBreaker}

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

reset() : $this

Response

$this

the current {@link CircuitBreaker}

retryPolicy

retryPolicy( $arg0) : $this

Arguments

$arg0

callable

Response

$this

state

state() : string

Response

string

the current state.