Skip to content

[HttpClient] simplify retry mechanism around RetryStrategyInterface #38532

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 13, 2020

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 12, 2020

Q A
Branch? 5.2
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Replaces #38466

I feel like the mechanism behind RetryableHttpClient is too bloated for no pragmatic reasons.

I propose to merge RetryDeciderInterface and RetryBackoffInterface into one single RetryStrategyInterface.

Having two separate interfaces supports no real-world use case. The only implementations we provide are trivial, and they can be reused by extending the provided GenericRetryStrategy implementation if one really doesn't want to duplicate that.

The methods are also simplified by accepting an AsyncContext as argument. This makes the signatures shorter and allows accessing the "info" of the request (allowing to decide based on the IP of the host, etc).

/cc @jderusse

Copy link
Member

@jderusse jderusse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new methods signatures.

Don't forget to update the FrameworkExtension

@nicolas-grekas nicolas-grekas force-pushed the hc-retry-strat branch 2 times, most recently from 5c31b3e to 4148f78 Compare October 13, 2020 07:23
Copy link
Member

@jderusse jderusse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nicolas-grekas. It's simpler like this.

use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;

/**
* Decides to retry the request when HTTP status codes belong to the given list of codes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should document that its delay implementation is an exponential backoff. That got lost when naming it generic.

@fabpot fabpot mentioned this pull request Oct 14, 2020
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Oct 21, 2020
This PR was merged into the 5.x branch.

Discussion
----------

Fix documentation about RetryStrategy

Change introduced in symfony/symfony#38532

Commits
-------

19521c3 Fix documentation about RetryStrategy
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.

4 participants