$next
$next : \Guzzle\Plugin\Backoff\AbstractBackoffStrategy
Strategy used to retry when certain error codes are encountered
$next : \Guzzle\Plugin\Backoff\AbstractBackoffStrategy
setNext(\Guzzle\Plugin\Backoff\AbstractBackoffStrategy $next)
\Guzzle\Plugin\Backoff\AbstractBackoffStrategy | $next | Next strategy in the chain |
getNext() : \Guzzle\Plugin\Backoff\AbstractBackoffStrategy|null
Get the next backoff strategy in the chain
getBackoffPeriod(integer $retries, \Guzzle\Http\Message\RequestInterface $request, \Guzzle\Http\Message\Response $response = null, \Guzzle\Http\Exception\HttpException $e = null) : boolean|integer
Get the amount of time to delay in seconds before retrying a request
integer | $retries | Number of retries of the request |
\Guzzle\Http\Message\RequestInterface | $request | Request that was sent |
\Guzzle\Http\Message\Response | $response | Response that was received. Note that there may not be a response |
\Guzzle\Http\Exception\HttpException | $e | Exception that was encountered if any |
Returns false to not retry or the number of seconds to delay between retries
__construct(array $codes = null, \Guzzle\Plugin\Backoff\BackoffStrategyInterface $next = null)
array | $codes | Array of codes that should be retried |
\Guzzle\Plugin\Backoff\BackoffStrategyInterface | $next | The optional next strategy |
getDelay(integer $retries, \Guzzle\Http\Message\RequestInterface $request, \Guzzle\Http\Message\Response $response = null, \Guzzle\Http\Exception\HttpException $e = null) : boolean|integer|null
Implement the concrete strategy
integer | $retries | Number of retries of the request |
\Guzzle\Http\Message\RequestInterface | $request | Request that was sent |
\Guzzle\Http\Message\Response | $response | Response that was received. Note that there may not be a response |
\Guzzle\Http\Exception\HttpException | $e | Exception that was encountered if any |
Returns false to not retry or the number of seconds to delay between retries. Return true or null to defer to the next strategy if available, and if not, return 0.
<?php
namespace Guzzle\Plugin\Backoff;
/**
* Strategy used to retry when certain error codes are encountered
*/
abstract class AbstractErrorCodeBackoffStrategy extends AbstractBackoffStrategy
{
/** @var array Default cURL errors to retry */
protected static $defaultErrorCodes = array();
/** @var array Error codes that can be retried */
protected $errorCodes;
/**
* @param array $codes Array of codes that should be retried
* @param BackoffStrategyInterface $next The optional next strategy
*/
public function __construct(array $codes = null, BackoffStrategyInterface $next = null)
{
$this->errorCodes = array_fill_keys($codes ?: static::$defaultErrorCodes, 1);
$this->next = $next;
}
/**
* Get the default failure codes to retry
*
* @return array
*/
public static function getDefaultFailureCodes()
{
return static::$defaultErrorCodes;
}
public function makesDecision()
{
return true;
}
}