Skip to content

RFC: update retry plugin backoff default to be more sensible #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spec/Plugin/RetryPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/Plugin/RetryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [])
Expand Down Expand Up @@ -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;
}
}