\Guzzle\Plugin\BackoffBackoffPlugin

Plugin to automatically retry failed HTTP requests using a backoff strategy

Summary

Methods
Properties
Constants
getAllEvents()
setEventDispatcher()
getEventDispatcher()
dispatch()
addSubscriber()
__construct()
getExponentialBackoff()
getSubscribedEvents()
onRequestSent()
onRequestPoll()
No public properties found
DELAY_PARAM
RETRY_PARAM
RETRY_EVENT
No protected methods found
$eventDispatcher
$strategy
N/A
No private methods found
No private properties found
N/A

Constants

DELAY_PARAM

DELAY_PARAM = \Guzzle\Http\Curl\CurlMultiInterface::BLOCKING

RETRY_PARAM

RETRY_PARAM = 'plugins.backoff.retry_count'

RETRY_EVENT

RETRY_EVENT = 'plugins.backoff.retry'

Properties

Methods

getAllEvents()

getAllEvents() : array

Get a list of all of the events emitted from the class

Returns

array

dispatch()

dispatch(string  $eventName, array  $context = array()) : \Guzzle\Common\Event

Helper to dispatch Guzzle events and set the event name on the event

Parameters

string $eventName

Name of the event to dispatch

array $context

Context of the event

Returns

\Guzzle\Common\Event

Returns the created event object

__construct()

__construct(\Guzzle\Plugin\Backoff\BackoffStrategyInterface  $strategy = null) 

Parameters

\Guzzle\Plugin\Backoff\BackoffStrategyInterface $strategy

The backoff strategy used to determine whether or not to retry and the amount of delay between retries.

getExponentialBackoff()

getExponentialBackoff(integer  $maxRetries = 3, array  $httpCodes = null, array  $curlCodes = null) : self

Retrieve a basic truncated exponential backoff plugin that will retry HTTP errors and cURL errors

Parameters

integer $maxRetries

Maximum number of retries

array $httpCodes

HTTP response codes to retry

array $curlCodes

cURL error codes to retry

Returns

self

getSubscribedEvents()

getSubscribedEvents() : array

Returns an array of event names this subscriber wants to listen to.

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • array('eventName' => 'methodName')
  • array('eventName' => array('methodName', $priority))
  • array('eventName' => array(array('methodName1', $priority), array('methodName2')))

Returns

array —

The event names to listen to

onRequestSent()

onRequestSent(\Guzzle\Common\Event  $event) 

Called when a request has been sent and isn't finished processing

Parameters

\Guzzle\Common\Event $event

onRequestPoll()

onRequestPoll(\Guzzle\Common\Event  $event) 

Called when a request is polling in the curl multi object

Parameters

\Guzzle\Common\Event $event