1: <?php
2:
3: namespace Guzzle\Plugin\Backoff;
4:
5: use Guzzle\Http\Message\RequestInterface;
6: use Guzzle\Http\Message\Response;
7: use Guzzle\Http\Exception\HttpException;
8:
9: /**
10: * Implements an exponential backoff retry strategy.
11: *
12: * Warning: If no decision making strategies precede this strategy in the the chain, then all requests will be retried
13: */
14: class ExponentialBackoffStrategy extends AbstractBackoffStrategy
15: {
16: /**
17: * {@inheritdoc}
18: */
19: public function makesDecision()
20: {
21: return false;
22: }
23:
24: /**
25: * {@inheritdoc}
26: */
27: protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
28: {
29: return (int) pow(2, $retries);
30: }
31: }
32: