8000 [HttpClient] add RetryStrategyInterface by nicolas-grekas · Pull Request #38420 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpClient] add RetryStrategyInterface #38420

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

Closed
wants to merge 1 commit into from

Conversation

nicolas-grekas
Copy link
Member
Q A
Branch? 5.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

Inspired by #38415, this gives more flexibility to the Retry\* logic.

Notably:

  • $retryCount is added to RetryDeciderInterface::shouldRetry()
  • a RetryToken value object is introduced, to provide greater extensibility (adding new methods in the retry logic will be easier via a class vs an interface) and to enable strategies to track a single request across retries (allowing to keep the strategy service stateless when request tracking is desired).
interface RetryStrategyInterface
{
    public function getToken(string $requestMethod, string $requestUrl, array $requestOptions): ?RetryToken;
}

For thoughts, /cc @jderusse

@fabpot fabpot closed this Oct 7, 2020
@nicolas-grekas nicolas-grekas deleted the hc-retry-strat branch October 7, 2020 16:06
@nicolas-grekas nicolas-grekas restored the hc-retry-strat branch October 7, 2020 16:06
@nicolas-grekas nicolas-grekas deleted the hc-retry-strat branch October 12, 2020 18:40
@nicolas-grekas nicolas-grekas modified the milestones: 5.2, 5.x Oct 14, 2020
fabpot added a commit that referenced this pull request Oct 20, 2020
…derusse)

This PR was merged into the 5.x branch.

Discussion
----------

[HttpClient] Parameterize list of retryable methods

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | /
| License       | MIT
| Doc PR        | TODO

Retrying non-idempotent methods is not always acceptable for user. This PR adds an easy way to configure this behavior.

The `RetryDeciderInterface::shouldRetry()` now take the exception in parameter, in order to let decider not retrying the request when the methods should never by retried.

With #38420, this code would belongs to the RetryStrategy implementation, and would return an `NeverRetryDecider` when method is not allowed.

Commits
-------

56809d1 Parameterize list of retryed Http methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0