Documentation

BackoffPlugin extends AbstractHasDispatcher
in package
implements EventSubscriberInterface

Plugin to automatically retry failed HTTP requests using a backoff strategy

Interfaces, Classes and Traits

EventSubscriberInterface
An EventSubscriber knows itself what events it is interested in.

Table of Contents

DELAY_PARAM  = GuzzleHttpCurlCurlMultiInterface::BLOCKING
RETRY_EVENT  = 'plugins.backoff.retry'
RETRY_PARAM  = 'plugins.backoff.retry_count'
$eventDispatcher  : EventDispatcherInterface
$strategy  : BackoffStrategyInterface
__construct()  : mixed
addSubscriber()  : self
Add an event subscriber to the dispatcher
dispatch()  : Event
Helper to dispatch Guzzle events and set the event name on the event
getAllEvents()  : array<string|int, mixed>
Get a list of all of the events emitted from the class
getEventDispatcher()  : EventDispatcherInterface
Get the EventDispatcher of the request
getExponentialBackoff()  : self
Retrieve a basic truncated exponential backoff plugin that will retry HTTP errors and cURL errors
getSubscribedEvents()  : array<string|int, mixed>
Returns an array of event names this subscriber wants to listen to.
onRequestPoll()  : mixed
Called when a request is polling in the curl multi object
onRequestSent()  : mixed
Called when a request has been sent and isn't finished processing
setEventDispatcher()  : self
Set the EventDispatcher of the request

Constants

DELAY_PARAM

public mixed DELAY_PARAM = GuzzleHttpCurlCurlMultiInterface::BLOCKING

RETRY_EVENT

public mixed RETRY_EVENT = 'plugins.backoff.retry'

RETRY_PARAM

public mixed RETRY_PARAM = 'plugins.backoff.retry_count'

Properties

Methods

dispatch()

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

public dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
$eventName : mixed

Name of the event to dispatch

$context : array<string|int, mixed> = array()

Context of the event

Return values
Event

Returns the created event object

getAllEvents()

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

public static getAllEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

getExponentialBackoff()

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

public static getExponentialBackoff([int $maxRetries = 3 ][, array<string|int, mixed> $httpCodes = null ][, array<string|int, mixed> $curlCodes = null ]) : self
Parameters
$maxRetries : int = 3

Maximum number of retries

$httpCodes : array<string|int, mixed> = null

HTTP response codes to retry

$curlCodes : array<string|int, mixed> = null

cURL error codes to retry

Return values
self

getSubscribedEvents()

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

public static getSubscribedEvents() : array<string|int, mixed>

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:

  • ['eventName' => 'methodName']
  • ['eventName' => ['methodName', $priority]]
  • ['eventName' => [['methodName1', $priority], ['methodName2']]]

The code must not depend on runtime state as it will only be called at compile time. All logic depending on runtime state must be put into the individual methods handling the events.

Return values
array<string|int, mixed>

The event names to listen to

onRequestPoll()

Called when a request is polling in the curl multi object

public onRequestPoll(Event $event) : mixed
Parameters
$event : Event
Return values
mixed

onRequestSent()

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

public onRequestSent(Event $event) : mixed
Parameters
$event : Event
Return values
mixed

Search results