Skip to content

Conversation

danielburger1337
Copy link
Contributor

References #50240

@carsonbot carsonbot added this to the 6.3 milestone May 5, 2023
@OskarStark OskarStark modified the milestones: 6.3, next May 6, 2023
@OskarStark OskarStark added Waiting Code Merge Docs for features pending to be merged HttpClient labels May 6, 2023
@carsonbot carsonbot changed the title Add 'max_retries' setting docs on the RetryableHttpClient [HttpClient] Add 'max_retries' setting docs on the RetryableHttpClient May 6, 2023
@OskarStark OskarStark changed the title [HttpClient] Add 'max_retries' setting docs on the RetryableHttpClient [HttpClient] Add max_retries setting docs on the RetryableHttpClient May 11, 2023
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Jun 9, 2023
…pClient` (danielburger1337)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[HttpClient] Add `max_retries` option to `RetryableHttpClient`

| 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
<?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]);
```

Commits
-------

496ba59 [HttpClient] Add `max_retries` option to `RetryableHttpClient`
symfony-splitter pushed a commit to symfony/http-client that referenced this pull request Jun 9, 2023
…pClient` (danielburger1337)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[HttpClient] Add `max_retries` option to `RetryableHttpClient`

| 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
<?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]);
```

Commits
-------

496ba59b4f [HttpClient] Add `max_retries` option to `RetryableHttpClient`
@OskarStark OskarStark removed the Waiting Code Merge Docs for features pending to be merged label Jun 9, 2023
@OskarStark OskarStark requested a review from nicolas-grekas June 9, 2023 09:37
@@ -713,7 +717,8 @@ By default, failed requests are retried up to 3 times, with an exponential delay
between retries (first retry = 1 second; third retry: 4 seconds) and only for
the following HTTP status codes: ``423``, ``425``, ``429``, ``502`` and ``503``
when using any HTTP method and ``500``, ``504``, ``507`` and ``510`` when using
an HTTP `idempotent method`_.
an HTTP `idempotent method`_. Use the ``max_retries`` setting to configure the amount
of times a request is retried.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
of times a request is retried.
of time a request is retried.

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.

LGTM (but that should target 6.4)

@OskarStark OskarStark modified the milestones: next, 6.4 Jun 9, 2023
@OskarStark OskarStark changed the base branch from 6.3 to 6.4 June 9, 2023 11:15
@OskarStark
Copy link
Contributor

Thanks for your work on this new feature!

@OskarStark OskarStark merged commit 8d59ced into symfony:6.4 Jun 9, 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.

4 participants