Skip to content

Instantly share code, notes, and snippets.

@jamiehannaford
Last active January 3, 2016 07:59
Show Gist options
  • Save jamiehannaford/8432889 to your computer and use it in GitHub Desktop.
Save jamiehannaford/8432889 to your computer and use it in GitHub Desktop.
add guzzle backoff strategy to client object
<?php
// First make sure you have the BackoffPlugin installed:
// $ composer require guzzle/guzzle
use Guzzle\Plugin\Backoff\BackoffPlugin;
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => 'foo',
'apiKey' => 'bar'
));
$maxRetries = 5;
$httpCodes = array(503);
$curlCodes = array(50);
$backoff = BackoffPlugin::getExponentialBackoff($maxRetries, $httpCodes, $curlCodes);
$client->addSubscriber($backoff);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment