-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Allow using multiple base_uri as array for retries #49809
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
Conversation
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
ghanks for starting this. We should also support default options, as is possible when using About what you say @GromNaN, it should also be possible to pass a list of per-hosts IPs to the resolve option, and rotate them as fits. This could be done either in this PR if @Tiriel is up to, or in a later one. Of course, that'd need resolving the many IPs outside of the client. One thing I'm wondering in both cases: shouldn't we shuffle the base URIs (and IPs later on?) |
@nicolas-grekas Sure thing, going to work on the default options! As for the IPs, I thought it would be better in another PR since the resolve doesn't take place at the same level, but maybe we can work something out. So I'd say that's up to @GromNaN , if you want to work on the feature yourself or not. |
Made an attempt to make it work with Haven't tried yet on the shuffling part, I'd like opinion on wether to shuffle by default or not, or on adding an option for this. |
About shuffling, we could to it this way:
Nested arrays would define shuffle groups, and first level values would be used in order. |
That's a great idea, thanks! |
Forgot to ping, but this has been updated with a shuffling attempt and tests accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified a bit the implementation, see https://github.com/symfony/symfony/compare/90b2027189ff18ca4957567e2252f570e3276d6d..b63ad4025ffbc4f1e513dd34650a34a50712afe4
I also removed the exception when the URL is absolute and a base URI is still provided because this is not an erroneous situation.
Lastly, I ensured that if the number of retries is higher than the number of base URIs, we stick retrying to the last one (possibly randomizing from a list).
Thank you @Tiriel. |
Looks more than a bit simplified to me, this is awesome work to look at and learn from! Thanks! |
@Tiriel Can you update the PR description with some code, please? It'll help Javier to write the living-on-the-edge articles |
@lyrixx Will do this evening! |
Updated PR description with usage, let me know if more is needed! |
…(Tiriel) This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [HttpClient] Add doc for multiple `base_uri` as array Add documentation for multiple base_uris in HttpClient (Symfony PR (merged): [symfony/symfony#49809](symfony/symfony#49809) ) Fixes #18224 Commits ------- 7244375 [HttpClient] Add doc for multiple `base_uri` as array
hi, thank you for the feature! |
Hi! Thanks for the feedback!
Not on my part. Going to write a fix for this asap! |
Allow array of `base_uri` in config for HttpClient keys, as per [comment in PR](symfony#49809 (comment)).
Allow array of `base_uri` in config for HttpClient keys, as per [comment in PR](symfony#49809 (comment)).
This pull request enhances the
RetryableHttpClient
by allowing the use of an array of URLs as thebase_uri
option. This enables retries on different base URIs for each retry attempt, providing increased reliability and flexibility for making HTTP requests.Basic usage :
Usage with base uri shuffling :