Skip to content

Commit 040d632

Browse files
authored
Merge pull request #86 from bendavies/retry-plugin-backoff-default
RFC: update retry plugin backoff default to be more sensible
2 parents 0245571 + f1990f9 commit 040d632

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

spec/Plugin/RetryPluginSpec.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ function it_does_not_keep_history_of_old_failure(RequestInterface $request, Resp
104104

105105
function it_has_an_exponential_default_delay(RequestInterface $request, Exception\HttpException $exception)
106106
{
107-
$this->defaultDelay($request, $exception, 0)->shouldBe(1000);
108-
$this->defaultDelay($request, $exception, 1)->shouldBe(2000);
109-
$this->defaultDelay($request, $exception, 2)->shouldBe(4000);
110-
$this->defaultDelay($request, $exception, 3)->shouldBe(8000);
107+
$this->defaultDelay($request, $exception, 0)->shouldBe(500000);
108+
$this->defaultDelay($request, $exception, 1)->shouldBe(1000000);
109+
$this->defaultDelay($request, $exception, 2)->shouldBe(2000000);
110+
$this->defaultDelay($request, $exception, 3)->shouldBe(4000000);
111111
}
112112
}

src/Plugin/RetryPlugin.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class RetryPlugin implements Plugin
4646
*
4747
* @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up.
4848
* @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried.
49-
* @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.
49+
* @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.
5050
* }
5151
*/
5252
public function __construct(array $config = [])
@@ -117,6 +117,6 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
117117
*/
118118
public static function defaultDelay(RequestInterface $request, Exception $e, $retries)
119119
{
120-
return pow(2, $retries) * 1000;
120+
return pow(2, $retries) * 500000;
121121
}
122122
}

0 commit comments

Comments
 (0)