Skip to content

Commit 7a60e75

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: [HttpClient] Reorganize the docs about the retry_failed option
2 parents 548edd0 + 4982a99 commit 7a60e75

File tree

1 file changed

+60
-31
lines changed

1 file changed

+60
-31
lines changed

reference/configuration/framework.rst

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -913,37 +913,6 @@ If you use for example
913913
as the type and name of an argument, autowiring will inject the ``my_api.client``
914914
service into your autowired classes.
915915

916-
.. _reference-http-client-retry-failed:
917-
918-
By enabling the optional ``retry_failed`` configuration, the HTTP client service
919-
will automatically retry failed HTTP requests.
920-
921-
.. code-block:: yaml
922-
923-
# config/packages/framework.yaml
924-
framework:
925-
# ...
926-
http_client:
927-
# ...
928-
default_options:
929-
retry_failed:
930-
# retry_strategy: app.custom_strategy
931-
http_codes:
932-
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
933-
429: true # retry all responses with 429 status code
934-
500: ['GET', 'HEAD']
935-
max_retries: 2
936-
delay: 1000
937-
multiplier: 3
938-
max_delay: 5000
939-
jitter: 0.3
940-
941-
scoped_clients:
942-
my_api.client:
943-
# ...
944-
retry_failed:
945-
max_retries: 4
946-
947916
auth_basic
948917
..........
949918

@@ -1058,6 +1027,8 @@ The minimum version of TLS to accept. The value must be one of the
10581027

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

1030+
.. _reference-http-client-retry-delay:
1031+
10611032
delay
10621033
.....
10631034

@@ -1097,6 +1068,8 @@ headers
10971068
An associative array of the HTTP headers added before making the request. This
10981069
value must use the format ``['header-name' => 'value0, value1, ...']``.
10991070

1071+
.. _reference-http-client-retry-http-codes:
1072+
11001073
http_codes
11011074
..........
11021075

@@ -1112,6 +1085,8 @@ http_version
11121085
The HTTP version to use, typically ``'1.1'`` or ``'2.0'``. Leave it to ``null``
11131086
to let Symfony select the best version automatically.
11141087

1088+
.. _reference-http-client-retry-jitter:
1089+
11151090
jitter
11161091
......
11171092

@@ -1139,6 +1114,8 @@ local_pk
11391114
The path of a file that contains the `PEM formatted`_ private key of the
11401115
certificate defined in the ``local_cert`` option.
11411116

1117+
.. _reference-http-client-retry-max-delay:
1118+
11421119
max_delay
11431120
.........
11441121

@@ -1173,6 +1150,8 @@ max_redirects
11731150
The maximum number of redirects to follow. Use ``0`` to not follow any
11741151
redirection.
11751152

1153+
.. _reference-http-client-retry-max-retries:
1154+
11761155
max_retries
11771156
...........
11781157

@@ -1181,6 +1160,8 @@ max_retries
11811160
The maximum number of retries for failing requests. When the maximum is reached,
11821161
the client returns the last received response.
11831162

1163+
.. _reference-http-client-retry-multiplier:
1164+
11841165
multiplier
11851166
..........
11861167

@@ -1248,6 +1229,54 @@ client and to make your tests easier.
12481229
The value of this option is an associative array of ``domain => IP address``
12491230
(e.g ``['symfony.com' => '46.137.106.254', ...]``).
12501231

1232+
.. _reference-http-client-retry-failed:
1233+
1234+
retry_failed
1235+
............
1236+
1237+
**type**: ``array``
1238+
1239+
.. versionadded:: 5.2
1240+
1241+
The ``retry_failed`` option was introduced in Symfony 5.2.
1242+
1243+
This option configures the behavior of the HTTP client when some request fails,
1244+
including which types of requests to retry and how many times. The behavior is
1245+
defined with the following options:
1246+
1247+
* :ref:`delay <reference-http-client-retry-delay>`
1248+
* :ref:`http_codes <reference-http-client-retry-http-codes>`
1249+
* :ref:`jitter <reference-http-client-retry-jitter>`
1250+
* :ref:`max_delay <reference-http-client-retry-max-delay>`
1251+
* :ref:`max_retries <reference-http-client-retry-max-retries>`
1252+
* :ref:`multiplier <reference-http-client-retry-multiplier>`
1253+
1254+
.. code-block:: yaml
1255+
1256+
# config/packages/framework.yaml
1257+
framework:
1258+
# ...
1259+
http_client:
1260+
# ...
1261+
default_options:
1262+
retry_failed:
1263+
# retry_strategy: app.custom_strategy
1264+
http_codes:
1265+
0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
1266+
429: true # retry all responses with 429 status code
1267+
500: ['GET', 'HEAD']
1268+
max_retries: 2
1269+
delay: 1000
1270+
multiplier: 3
1271+
max_delay: 5000
1272+
jitter: 0.3
1273+
1274+
scoped_clients:
1275+
my_api.client:
1276+
# ...
1277+
retry_failed:
1278+
max_retries: 4
1279+
12511280
retry_strategy
12521281
..............
12531282

0 commit comments

Comments
 (0)