An implementation of the circuit breaker pattern for Vert.x
package |
Default |
---|
__construct()
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.
$this
closeHandler( $arg0) : $this
callable
$this
the current {@link CircuitBreaker}
create( $arg0, $arg1, $arg2 = null) : \io\vertx\jphp\circuitbreaker\CircuitBreaker
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)
string
Vertx
array | CircuitBreakerOptions
\io\vertx\jphp\circuitbreaker\CircuitBreaker
the created instance
execute( $arg0) : \io\vertx\jphp\circuitbreaker\Future<T>
callable
\io\vertx\jphp\circuitbreaker\Future
a future object completed when the operation or its fallback completes
executeAndReport( $arg0, $arg1) : $this
Future
callable
$this
the current {@link CircuitBreaker}
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.
Future
callable
callable
$this
the current {@link CircuitBreaker}
executeCommand( $arg0, $arg1) : void
callable
callable
executeCommandWithFallback( $arg0, $arg1, $arg2) : void
callable
callable
callable
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.
callable
callable
\io\vertx\jphp\circuitbreaker\Future
a future object completed when the operation or its fallback completes
failureCount() : integer
integer
the current number of failures.
fallback( $arg0) : $this
The function gets the exception as parameter and returns the fallback result.
callable
$this
the current {@link CircuitBreaker}
halfOpenHandler( $arg0) : $this
callable
$this
the current {@link CircuitBreaker}
name() : string
string
the name of the circuit breaker.
open() : $this
$this
the current {@link CircuitBreaker}
openHandler( $arg0) : $this
callable
$this
the current {@link CircuitBreaker}
reset() : $this
$this
the current {@link CircuitBreaker}
retryPolicy( $arg0) : $this
callable
$this
state() : string
string
the current state.