Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [HttpClient] Reorganize the docs about the retry_failed option
  • Loading branch information
javiereguiluz committed Jun 18, 2024
2 parents cf8f710 + 24af1da commit d6aba6f
Showing 1 changed file with 64 additions and 31 deletions.
95 changes: 64 additions & 31 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -862,37 +862,6 @@ If you use for example
as the type and name of an argument, autowiring will inject the ``my_api.client``
service into your autowired classes.

.. _reference-http-client-retry-failed:

By enabling the optional ``retry_failed`` configuration, the HTTP client service
will automatically retry failed HTTP requests.

.. code-block:: yaml
# config/packages/framework.yaml
framework:
# ...
http_client:
# ...
default_options:
retry_failed:
# retry_strategy: app.custom_strategy
http_codes:
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
429: true # retry all responses with 429 status code
500: ['GET', 'HEAD']
max_retries: 2
delay: 1000
multiplier: 3
max_delay: 5000
jitter: 0.3
scoped_clients:
my_api.client:
# ...
retry_failed:
max_retries: 4
auth_basic
..........

Expand Down Expand Up @@ -1003,6 +972,12 @@ crypto_method
The minimum version of TLS to accept. The value must be one of the
``STREAM_CRYPTO_METHOD_TLSv*_CLIENT`` constants defined by PHP.

.. versionadded:: 6.3

Check failure on line 975 in reference/configuration/framework.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

You are not allowed to use version "6.3". Only major version "7" is allowed.

Check failure on line 975 in reference/configuration/framework.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please only provide ".. versionadded::" if the version is greater/equal "7.0"

The ``crypto_method`` option was introduced in Symfony 6.3.

.. _reference-http-client-retry-delay:

delay
.....

Expand Down Expand Up @@ -1038,6 +1013,8 @@ headers
An associative array of the HTTP headers added before making the request. This
value must use the format ``['header-name' => 'value0, value1, ...']``.

.. _reference-http-client-retry-http-codes:

http_codes
..........

Expand All @@ -1053,6 +1030,8 @@ http_version
The HTTP version to use, typically ``'1.1'`` or ``'2.0'``. Leave it to ``null``
to let Symfony select the best version automatically.

.. _reference-http-client-retry-jitter:

jitter
......

Expand Down Expand Up @@ -1080,6 +1059,8 @@ local_pk
The path of a file that contains the `PEM formatted`_ private key of the
certificate defined in the ``local_cert`` option.

.. _reference-http-client-retry-max-delay:

max_delay
.........

Expand Down Expand Up @@ -1114,6 +1095,8 @@ max_redirects
The maximum number of redirects to follow. Use ``0`` to not follow any
redirection.

.. _reference-http-client-retry-max-retries:

max_retries
...........

Expand All @@ -1122,6 +1105,8 @@ max_retries
The maximum number of retries for failing requests. When the maximum is reached,
the client returns the last received response.

.. _reference-http-client-retry-multiplier:

multiplier
..........

Expand Down Expand Up @@ -1202,6 +1187,54 @@ client and to make your tests easier.
The value of this option is an associative array of ``domain => IP address``
(e.g ``['symfony.com' => '46.137.106.254', ...]``).

.. _reference-http-client-retry-failed:

retry_failed
............

**type**: ``array``

.. versionadded:: 5.2

Check failure on line 1197 in reference/configuration/framework.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

You are not allowed to use version "5.2". Only major version "7" is allowed.

Check failure on line 1197 in reference/configuration/framework.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please only provide ".. versionadded::" if the version is greater/equal "7.0"

The ``retry_failed`` option was introduced in Symfony 5.2.

This option configures the behavior of the HTTP client when some request fails,
including which types of requests to retry and how many times. The behavior is
defined with the following options:

* :ref:`delay <reference-http-client-retry-delay>`
* :ref:`http_codes <reference-http-client-retry-http-codes>`
* :ref:`jitter <reference-http-client-retry-jitter>`
* :ref:`max_delay <reference-http-client-retry-max-delay>`
* :ref:`max_retries <reference-http-client-retry-max-retries>`
* :ref:`multiplier <reference-http-client-retry-multiplier>`

.. code-block:: yaml
# config/packages/framework.yaml
framework:
# ...
http_client:
# ...
default_options:
retry_failed:
# retry_strategy: app.custom_strategy
http_codes:
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
429: true # retry all responses with 429 status code
500: ['GET', 'HEAD']
max_retries: 2
delay: 1000
multiplier: 3
max_delay: 5000
jitter: 0.3
scoped_clients:
my_api.client:
# ...
retry_failed:
max_retries: 4
retry_strategy
..............

Expand Down

0 comments on commit d6aba6f

Please sign in to comment.