8000 [HttpClient] Add `max_retries` option to `RetryableHttpClient` by danielburger1337 · Pull Request #50240 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpClient] Add max_retries option to RetryableHttpClient #50240

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 cli 8000 cking “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
Jun 9, 2023
Merged

[HttpClient] Add max_retries option to RetryableHttpClient #50240

merged 1 commit into from
Jun 9, 2023

Conversation

danielburger1337
Copy link
Contributor
@danielburger1337 danielburger1337 commented May 4, 2023
Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets N/A
License MIT
Doc PR symfony/symfony-docs#18288

Added a max_retries option to RetryableHttpClient that allows the user to configure the RetryableHttpClient on a per request level, which is especially useful when retry_failed was configured for the global http_client service.

<?php

use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\RetryableHttpClient;

$client = HttpClient::create();
$client = new RetryableHttpClient($client, null, 3);

$client->request('GET', '/foo-bar', [
    'max_retries' => 1 // 0 disables retrying
]);

// $client = $client->withOptions(['max_retries' => 1]);

@nicolas-grekas
Copy link
Member
nicolas-grekas commented May 5, 2023

What about adding max_retries instead? this would be more flexible.
Note that this doesn't need to be an "extra" option - it shouldn't actually.
This will need to override the withOptions method also.
You might want to take some inspiration from UriTemplateHttpClient, which also manages its own option.

@danielburger1337
Copy link
Contributor Author

What about adding max_retries instead? this would be more flexible. Not that this doesn't need to be an "extra" option - it shouldn't actually. This will need to override the withOptions method also. You might want to take some inspiration from UriTemplateHttpClient, which also manages its own option.

Yes, this would be much more flexible approach and I like it!

To be extra clear, would this option overide the maxRetries property of the RetryableHttpClient when cloned?
Because otherwise I'm not quite sure what you mean.

@nicolas-grekas
Copy link
Member

Yes, it would override it indeed.

@danielburger1337 danielburger1337 changed the title [HttpClient] Add "no_retry" option to RetryableHttpClient [HttpClient] Add "max_retries" option to RetryableHttpClient May 5, 2023
@OskarStark
Copy link
Contributor
OskarStark commented May 6, 2023

Can you please update the pr header? You still mention no_retry. Thanks

@danielburger1337
Copy link
Contributor Author

Can you please update the pr header? You still mention no_retry. Thanks

What do you mean by PR header? Do you mean my original PR description?

Sorry, I never heard that term before.

@OskarStark
Copy link
Contributor

Yes the PR description and the code example. Thanks

@danielburger1337
Copy link
Contributor Author

Yes the PR description and the code example. Thanks

Done

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Look good to me thanks. I just have a minor comment.

@OskarStark OskarStark changed the title [HttpClient] Add "max_retries" option to RetryableHttpClient [HttpClient] Add max_retries option to RetryableHttpClient May 16, 2023
@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 May 23, 2023
@nicolas-grekas
Copy link
Member

Thank you @danielburger1337.

@nicolas-grekas nicolas-grekas merged commit 52a9292 into symfony:6.4 Jun 9, 2023
OskarStark added a commit to symfony/symfony-docs that referenced this pull request Jun 9, 2023
…tryableHttpClient` (danielburger1337)

This PR was submitted for the 6.3 branch but it was merged into the 6.4 branch instead.

Discussion
----------

[HttpClient] Add `max_retries` setting docs on the `RetryableHttpClient`

References [#50240](symfony/symfony#50240)

Commits
-------

bf57a3e Add 'max_retries' setting docs on the RetryableHttpClient
This was referenced Oct 21, 2023
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.

5 participants
0