CommandRetry
in package
Allows any action to be retried in case of an exception.
This class can be parametrized with a strategy, which will be followed to determine whether the action should be retried.
Table of Contents
Properties
- $maxRetries : int
- $numRetries : int
- $strategy : RetryStrategyInterface
- The strategy to follow should the executed action fail.
Methods
- __construct() : mixed
- Creates the CommandRetry object with the given strategy and retry count
- getRetries() : int
- Returns the last number of retry attemps.
- run() : mixed
- The number of retries to perform in case of failure
Properties
$maxRetries
protected
int
$maxRetries
$numRetries
protected
int
$numRetries
$strategy
The strategy to follow should the executed action fail.
protected
RetryStrategyInterface
$strategy
Methods
__construct()
Creates the CommandRetry object with the given strategy and retry count
public
__construct(RetryStrategyInterface $strategy[, int $maxRetries = 1 ]) : mixed
Parameters
- $strategy : RetryStrategyInterface
-
The strategy to follow should the action fail
- $maxRetries : int = 1
-
The maximum number of retry attempts allowed
getRetries()
Returns the last number of retry attemps.
public
getRetries() : int
Return values
intrun()
The number of retries to perform in case of failure
public
run(callable $action) : mixed
Parameters
- $action : callable
-
The callable action to execute with a retry strategy
Tags
Return values
mixed —The return value of the passed action callable