Open Journal Systems  3.3.0
Guzzle\Plugin\Backoff\BackoffPlugin Class Reference
Inheritance diagram for Guzzle\Plugin\Backoff\BackoffPlugin:
Guzzle\Common\AbstractHasDispatcher Symfony\Component\EventDispatcher\EventSubscriberInterface Guzzle\Common\HasDispatcherInterface

Public Member Functions

 __construct (BackoffStrategyInterface $strategy=null)
 
 onRequestPoll (Event $event)
 
 onRequestSent (Event $event)
 
- Public Member Functions inherited from Guzzle\Common\AbstractHasDispatcher
 addSubscriber (EventSubscriberInterface $subscriber)
 
 dispatch ($eventName, array $context=array())
 
 getEventDispatcher ()
 
 setEventDispatcher (EventDispatcherInterface $eventDispatcher)
 

Static Public Member Functions

static getAllEvents ()
 
static getExponentialBackoff ( $maxRetries=3, array $httpCodes=null, array $curlCodes=null)
 
static getSubscribedEvents ()
 

Data Fields

const DELAY_PARAM = CurlMultiInterface::BLOCKING
 
const RETRY_EVENT = 'plugins.backoff.retry'
 
const RETRY_PARAM = 'plugins.backoff.retry_count'
 

Protected Attributes

 $strategy
 
- Protected Attributes inherited from Guzzle\Common\AbstractHasDispatcher
 $eventDispatcher
 

Detailed Description

Plugin to automatically retry failed HTTP requests using a backoff strategy

Definition at line 16 of file BackoffPlugin.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Plugin\Backoff\BackoffPlugin::__construct ( BackoffStrategyInterface  $strategy = null)
Parameters
BackoffStrategyInterface$strategyThe backoff strategy used to determine whether or not to retry and the amount of delay between retries.

Definition at line 32 of file BackoffPlugin.php.

References Guzzle\Plugin\Backoff\BackoffPlugin\$strategy.

Member Function Documentation

◆ getAllEvents()

static Guzzle\Plugin\Backoff\BackoffPlugin::getAllEvents ( )
static

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

Returns
array

Reimplemented from Guzzle\Common\AbstractHasDispatcher.

Definition at line 60 of file BackoffPlugin.php.

Referenced by Guzzle\Tests\Plugin\Backoff\BackoffPluginTest\testHasEventList().

◆ getExponentialBackoff()

static Guzzle\Plugin\Backoff\BackoffPlugin::getExponentialBackoff (   $maxRetries = 3,
array  $httpCodes = null,
array  $curlCodes = null 
)
static

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

Parameters
int$maxRetriesMaximum number of retries
array$httpCodesHTTP response codes to retry
array$curlCodescURL error codes to retry
Returns
self

Definition at line 46 of file BackoffPlugin.php.

Referenced by Guzzle\Tests\Plugin\Backoff\BackoffPluginTest\testCreatesDefaultExponentialBackoffPlugin().

◆ getSubscribedEvents()

static Guzzle\Plugin\Backoff\BackoffPlugin::getSubscribedEvents ( )
static

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

Implements Symfony\Component\EventDispatcher\EventSubscriberInterface.

Definition at line 65 of file BackoffPlugin.php.

References Guzzle\Http\Curl\CurlMultiInterface\POLLING_REQUEST.

◆ onRequestPoll()

Guzzle\Plugin\Backoff\BackoffPlugin::onRequestPoll ( Event  $event)

Called when a request is polling in the curl multi object

Parameters
Event$event

Definition at line 110 of file BackoffPlugin.php.

References Guzzle\Http\Message\EntityEnclosingRequestInterface\getBody().

◆ onRequestSent()

Guzzle\Plugin\Backoff\BackoffPlugin::onRequestSent ( Event  $event)

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

Parameters
Event$event

Definition at line 79 of file BackoffPlugin.php.

References Guzzle\Common\AbstractHasDispatcher\dispatch(), and Guzzle\Http\Message\RequestInterface\STATE_TRANSFER.

Field Documentation

◆ $strategy

BackoffStrategyInterface Guzzle\Plugin\Backoff\BackoffPlugin::$strategy
protected

Backoff strategy

Definition at line 26 of file BackoffPlugin.php.

Referenced by Guzzle\Plugin\Backoff\BackoffPlugin\__construct().

◆ DELAY_PARAM

◆ RETRY_EVENT

const Guzzle\Plugin\Backoff\BackoffPlugin::RETRY_EVENT = 'plugins.backoff.retry'

◆ RETRY_PARAM

const Guzzle\Plugin\Backoff\BackoffPlugin::RETRY_PARAM = 'plugins.backoff.retry_count'

The documentation for this class was generated from the following file: