@@ -731,6 +731,59 @@ The ``RetryableHttpClient`` uses a
731731decide if the request should be retried, and to define the waiting time between
732732each retry.
733733
734+ Retry Over Several Base URIs
735+ ............................
736+
737+ .. versionadded :: 6.3
738+
739+ The multiple ``base_uri `` feature was added in Symfony 6.3.
740+
741+ The ``RetryableHttpClient `` can be configured to use multiple base URIs. This
742+ feature provides increased flexibility and reliability for making HTTP
743+ requests. Pass an array of base URIs as option ``base_uri `` when making a
744+ request::
745+
746+ $response = $client->request('GET', 'some-page', [
747+ 'base_uri' => [
748+ // first request will use this base URI
749+ 'https://example.com/a/',
750+ // if first request fails, the following base URI will be used
751+ 'https://example.com/b/',
752+ ],
753+ ]);
754+
755+ When the number of retries is higher than the number of base URIs, the
756+ last base URI will be used for the remaining retries.
757+
758+ If you want to shuffle the order of base URIs for each retry attempt, nest the
759+ base URIs you want to shuffle in an additional array::
760+
761+ $response = $client->request('GET', 'some-page', [
762+ 'base_uri' => [
763+ [
764+ // a single random URI from this array will be used for the first request
765+ 'https://example.com/a/',
766+ 'https://example.com/b/',
767+ ],
768+ // non-nested base URIs are used in order
769+ 'https://example.com/c/',
770+ ],
771+ ]);
772+
773+ This feature allows for a more randomized approach to handling retries,
774+ reducing the likelihood of repeatedly hitting the same failed base URI.
775+
776+ By using a nested array for the base URI, you can use this feature
777+ to distribute the load among many nodes in a cluster of servers.
778+
779+ You can also configure the array of base URIs using the ``withOptions() ``
780+ method::
781+
782+ $client = $client->withOptions(['base_uri' => [
783+ 'https://example.com/a/',
784+ 'https://example.com/b/',
785+ ]]);
786+
734787HTTP Proxies
735788~~~~~~~~~~~~
736789
0 commit comments