Skip to content

Commit 5704363

Browse files
committed
[HttpClient] Reorganize the docs about the retry_failed option
1 parent 2071829 commit 5704363

File tree

1 file changed

+60
-35
lines changed

1 file changed

+60
-35
lines changed

reference/configuration/framework.rst

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -887,41 +887,6 @@ If you use for example
887887
as the type and name of an argument, autowiring will inject the ``my_api.client``
888888
service into your autowired classes.
889889

890-
.. _reference-http-client-retry-failed:
891-
892-
By enabling the optional ``retry_failed`` configuration, the HTTP client service
893-
will automatically retry failed HTTP requests.
894-
895-
.. code-block:: yaml
896-
897-
# config/packages/framework.yaml
898-
framework:
899-
# ...
900-
http_client:
901-
# ...
902-
default_options:
903-
retry_failed:
904-
# retry_strategy: app.custom_strategy
905-
http_codes:
906-
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
907-
429: true # retry all responses with 429 status code
908-
500: ['GET', 'HEAD']
909-
max_retries: 2
910-
delay: 1000
911-
multiplier: 3
912-
max_delay: 5000
913-
jitter: 0.3
914-
915-
scoped_clients:
916-
my_api.client:
917-
# ...
918-
retry_failed:
919-
max_retries: 4
920-
921-
.. versionadded:: 5.2
922-
923-
The ``retry_failed`` option was introduced in Symfony 5.2.
924-
925890
auth_basic
926891
..........
927892

@@ -1024,6 +989,8 @@ ciphers
1024989
A list of the names of the ciphers allowed for the SSL/TLS connections. They
1025990
can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256'``).
1026991

992+
.. _reference-http-client-retry-delay:
993+
1027994
delay
1028995
.....
1029996

@@ -1055,6 +1022,8 @@ headers
10551022
An associative array of the HTTP headers added before making the request. This
10561023
value must use the format ``['header-name' => 'value0, value1, ...']``.
10571024

1025+
.. _reference-http-client-retry-http-codes:
1026+
10581027
http_codes
10591028
..........
10601029

@@ -1074,6 +1043,8 @@ http_version
10741043
The HTTP version to use, typically ``'1.1'`` or ``'2.0'``. Leave it to ``null``
10751044
to let Symfony select the best version automatically.
10761045

1046+
.. _reference-http-client-retry-jitter:
1047+
10771048
jitter
10781049
......
10791050

@@ -1105,6 +1076,8 @@ local_pk
11051076
The path of a file that contains the `PEM formatted`_ private key of the
11061077
certificate defined in the ``local_cert`` option.
11071078

1079+
.. _reference-http-client-retry-max-delay:
1080+
11081081
max_delay
11091082
.........
11101083

@@ -1143,6 +1116,8 @@ max_redirects
11431116
The maximum number of redirects to follow. Use ``0`` to not follow any
11441117
redirection.
11451118

1119+
.. _reference-http-client-retry-max-retries:
1120+
11461121
max_retries
11471122
...........
11481123

@@ -1155,6 +1130,8 @@ max_retries
11551130
The maximum number of retries for failing requests. When the maximum is reached,
11561131
the client returns the last received response.
11571132

1133+
.. _reference-http-client-retry-multiplier:
1134+
11581135
multiplier
11591136
..........
11601137

@@ -1226,6 +1203,54 @@ client and to make your tests easier.
12261203
The value of this option is an associative array of ``domain => IP address``
12271204
(e.g ``['symfony.com' => '46.137.106.254', ...]``).
12281205

1206+
.. _reference-http-client-retry-failed:
1207+
1208+
retry_failed
1209+
............
1210+
1211+
**type**: ``array``
1212+
1213+
.. versionadded:: 5.2
1214+
1215+
The ``retry_failed`` option was introduced in Symfony 5.2.
1216+
1217+
This option configures the behavior of the HTTP client when some request fails,
1218+
including which types of requests to retry and how many times. The behavior is
1219+
defined with the following options:
1220+
1221+
* :ref:`delay <reference-http-client-retry-delay>`
1222+
* :ref:`http_codes <reference-http-client-retry-http-codes>`
1223+
* :ref:`jitter <reference-http-client-retry-jitter>`
1224+
* :ref:`max_delay <reference-http-client-retry-max-delay>`
1225+
* :ref:`max_retries <reference-http-client-retry-max-retries>`
1226+
* :ref:`multiplier <reference-http-client-retry-multiplier>`
1227+
1228+
.. code-block:: yaml
1229+
1230+
# config/packages/framework.yaml
1231+
framework:
1232+
# ...
1233+
http_client:
1234+
# ...
1235+
default_options:
1236+
retry_failed:
1237+
# retry_strategy: app.custom_strategy
1238+
http_codes:
1239+
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
1240+
429: true # retry all responses with 429 status code
1241+
500: ['GET', 'HEAD']
1242+
max_retries: 2
1243+
delay: 1000
1244+
multiplier: 3
1245+
max_delay: 5000
1246+
jitter: 0.3
1247+
1248+
scoped_clients:
1249+
my_api.client:
1250+
# ...
1251+
retry_failed:
1252+
max_retries: 4
1253+
12291254
retry_strategy
12301255
..............
12311256

0 commit comments

Comments
 (0)