Skip to content

Commit 7f0e8d8

Browse files
committed
Tweaks and rewords
1 parent 2fed71a commit 7f0e8d8

File tree

2 files changed

+56
-21
lines changed

2 files changed

+56
-21
lines changed

http_client.rst

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,23 @@ making a request. Use the ``max_redirects`` setting to configure this behavior
658658
Retry Failed Requests
659659
~~~~~~~~~~~~~~~~~~~~~
660660

661-
Some times, requests failed because of temporary issue in the server or
662-
because network issue. You can use the
663-
:class:`Symfony\\Component\\HttpClient\\RetryableHttpClient`
664-
client to automatically retry the request when it fails.::
661+
.. versionadded:: 5.2
662+
663+
The feature to retry failed HTTP requests was introduced in Symfony 5.2.
664+
665+
Sometimes, requests fail because of network issues or temporary server errors.
666+
Symfony's HttpClient allows to retry failed requests automatically using the
667+
:ref:`retry_failed option <reference-http-client-retry-failed>`. When enabled,
668+
each failed request with an HTTP status of ``423``, ``425``, ``429``, ``500``,
669+
``502``, ``503``, ``504``, ``507``, or ``510`` is retried up to 3 times, with an
670+
exponential delay between retries (first retry = 1 second; third retry: 4 seconds).
671+
672+
Check out the full list of configurable :ref:`retry_failed options <reference-http-client-retry-failed>`
673+
to learn how to tweak each of them to fit your application needs.
674+
675+
When using the HttpClient outside of a Symfony application, use the
676+
:class:`Symfony\\Component\\HttpClient\\RetryableHttpClient` class to wrap your
677+
original HTTP client::
665678

666679
use Symfony\Component\HttpClient\RetryableHttpClient;
667680

@@ -673,10 +686,6 @@ decide if the request should be retried, and a
673686
:class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface` to
674687
define the waiting time between each retry.
675688

676-
By default, it retries until 3 attemps, the requests responding with a
677-
status code in (423, 425, 429, 500, 502, 503, 504, 507 or 510) and wait
678-
expentially from 1 second for the first retry, to 4 seconds at the 3rd attempt.
679-
680689
HTTP Proxies
681690
~~~~~~~~~~~~
682691

reference/configuration/framework.rst

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,10 @@ will automaticaly retry failed HTTP requests.
792792
retry_failed:
793793
max_retries: 4
794794
795+
.. versionadded:: 5.2
796+
797+
The ``retry_failed`` option was introduced in Symfony 5.2.
798+
795799
auth_basic
796800
..........
797801

@@ -824,13 +828,15 @@ backoff_service
824828

825829
**type**: ``string``
826830

831+
.. versionadded:: 5.2
832+
833+
The ``backoff_service`` option was introduced in Symfony 5.2.
834+
827835
The service id used to compute the time to wait between retries. By default, it
828836
uses an instance of
829837
:class:`Symfony\\Component\\HttpClient\\Retry\\ExponentialBackOff` configured
830838
with ``delay``, ``max_delay`` and ``multiplier`` options. This class has to
831839
implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface`.
832-
This options cannot be used along `delay`_, `max_delay`_ or `multiplier`_
833-
options.
834840

835841
base_uri
836842
........
@@ -905,20 +911,26 @@ decider_service
905911

906912
**type**: ``string``
907913

914+
.. versionadded:: 5.2
915+
916+
The ``decider_service`` option was introduced in Symfony 5.2.
917+
908918
The service id used to decide if a request should be retried. By default, it
909919
uses an instance of
910920
:class:`Symfony\\Component\\HttpClient\\Retry\\HttpStatusCodeDecider` configured
911-
with ``http_codes`` options. This class has to
912-
implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface`.
913-
This options cannot be used along `http_codes`_ option.
921+
with the ``http_codes`` option. This class has to implement
922+
:class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface`.
914923

915924
delay
916925
.....
917926

918927
**type**: ``integer`` **default**: ``1000``
919928

920-
The initial delay in milliseconds used to compute the waiting time between
921-
retries. This options cannot be used along `backoff_service`_ option.
929+
.. versionadded:: 5.2
930+
931+
The ``delay`` option was introduced in Symfony 5.2.
932+
933+
The initial delay in milliseconds used to compute the waiting time between retries.
922934

923935
.. _reference-http-client-retry-enabled:
924936

@@ -943,8 +955,11 @@ http_codes
943955

944956
**type**: ``array`` **default**: ``[423, 425, 429, 500, 502, 503, 504, 507, 510]``
945957

958+
.. versionadded:: 5.2
959+
960+
The ``http_codes`` option was introduced in Symfony 5.2.
961+
946962
The list of HTTP status codes that triggers a retry of the request.
947-
This options cannot be used along `decider_service`_ option.
948963

949964
http_version
950965
............
@@ -976,9 +991,12 @@ max_delay
976991

977992
**type**: ``integer`` **default**: ``0``
978993

994+
.. versionadded:: 5.2
995+
996+
The ``max_delay`` option was introduced in Symfony 5.2.
997+
979998
The maximum amount of milliseconds initial to wait between retries.
980999
Use ``0`` to not limit the duration.
981-
This options cannot be used along `backoff_service`_ option.
9821000

9831001
max_duration
9841002
............
@@ -1011,16 +1029,24 @@ max_retries
10111029

10121030
**type**: ``integer`` **default**: ``3``
10131031

1014-
The maximum number of retries before aborting. When the maximum is reach, the
1015-
client returns the last received responses.
1032+
.. versionadded:: 5.2
1033+
1034+
The ``max_retries`` option was introduced in Symfony 5.2.
1035+
1036+
The maximum number of retries for failing requests. When the maximum is reached,
1037+
the client returns the last received response.
10161038

10171039
multiplier
10181040
..........
10191041

10201042
**type**: ``float`` **default**: ``2``
10211043

1022-
Multiplier to apply to the delay each time a retry occurs.
1023-
This options cannot be used along `backoff_service`_ option.
1044+
.. versionadded:: 5.2
1045+
1046+
The ``multiplier`` option was introduced in Symfony 5.2.
1047+
1048+
This value is multiplied to the delay each time a retry occurs, to distribute
1049+
retries in time instead of making all of them sequentially.
10241050

10251051
no_proxy
10261052
........

0 commit comments

Comments
 (0)