Last active
January 3, 2016 07:59
-
-
Save jamiehannaford/8432889 to your computer and use it in GitHub Desktop.
add guzzle backoff strategy to client object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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