From 728e3b372dcca5637df74a060813c7383bae62a5 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 2 Mar 2014 17:59:08 +0100 Subject: [PATCH] Adding BackoffRetryPlugin from Guzzle. --- lib/Tmdb/Client.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index 0d4c2a74..4e109603 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -17,6 +17,7 @@ use Guzzle\Common\HasDispatcherInterface; use Guzzle\Http\Client as GuzzleClient; use Guzzle\Http\ClientInterface; +use Guzzle\Plugin\Backoff\BackoffPlugin; use Guzzle\Plugin\Cache\CachePlugin; use Guzzle\Plugin\Cache\DefaultCacheStorage; use Tmdb\HttpClient\HttpClient; @@ -118,6 +119,9 @@ private function constructHttpClient(ClientInterface $httpClient = null) $acceptJsonHeaderPlugin = new AcceptJsonHeaderPlugin(); $httpClient->addSubscriber($acceptJsonHeaderPlugin); + $backoffPlugin = BackoffPlugin::getExponentialBackoff(5); + $httpClient->addSubscriber($backoffPlugin); + if ($this->getToken() instanceof ApiToken) { $apiTokenPlugin = new ApiTokenPlugin($this->getToken()); $httpClient->addSubscriber($apiTokenPlugin);