diff --git a/spec/Plugin/RetryPluginSpec.php b/spec/Plugin/RetryPluginSpec.php index 269e90a..37800ae 100644 --- a/spec/Plugin/RetryPluginSpec.php +++ b/spec/Plugin/RetryPluginSpec.php @@ -104,9 +104,9 @@ function it_does_not_keep_history_of_old_failure(RequestInterface $request, Resp function it_has_an_exponential_default_delay(RequestInterface $request, Exception\HttpException $exception) { - $this->defaultDelay($request, $exception, 0)->shouldBe(1000); - $this->defaultDelay($request, $exception, 1)->shouldBe(2000); - $this->defaultDelay($request, $exception, 2)->shouldBe(4000); - $this->defaultDelay($request, $exception, 3)->shouldBe(8000); + $this->defaultDelay($request, $exception, 0)->shouldBe(500000); + $this->defaultDelay($request, $exception, 1)->shouldBe(1000000); + $this->defaultDelay($request, $exception, 2)->shouldBe(2000000); + $this->defaultDelay($request, $exception, 3)->shouldBe(4000000); } } diff --git a/src/Plugin/RetryPlugin.php b/src/Plugin/RetryPlugin.php index 1a58004..8446246 100644 --- a/src/Plugin/RetryPlugin.php +++ b/src/Plugin/RetryPlugin.php @@ -46,7 +46,7 @@ final class RetryPlugin implements Plugin * * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up. * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried. - * @var callable $delay A callback that gets a request, an exception and the number of retries and returns how many milliseconds we should wait before trying again. + * @var callable $delay A callback that gets a request, an exception and the number of retries and returns how many microseconds we should wait before trying again. * } */ public function __construct(array $config = []) @@ -117,6 +117,6 @@ public function handleRequest(RequestInterface $request, callable $next, callabl */ public static function defaultDelay(RequestInterface $request, Exception $e, $retries) { - return pow(2, $retries) * 1000; + return pow(2, $retries) * 500000; } }