Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Retry failed client requests #1562
In situations when the client fails with certain error codes,
In situations when the client fails with certain error codes, it should be able to retry the request. Ideally, it would retry the request to a different host so that in the event that an instance malfunctioned or was removed, the request wasn't consistently failing.
The guava retrying looks pretty straightforward. Some things to keep in mind:
In particular, make retry more configurable by allowing the user to set the number of attempts and the strategy to determine whether a response should be retried. Also explicitly disabled retries on the request, so that it would be entirely handled within the Guava retryer. The reason that retries within the HttpClient can't be re-used is that doing so would just retry the given HttpRequest, and this needs to be able to alter the HttpRequest between attempts. Also is a little more careful about retrying to different hosts on requests.
I was doing something that looked like ``` url = hostToUrl(host) actualUrl = hostToUrl(url) ``` which was very obviously wrong. This fixes it so that it only builds the URL once, which is the correct write way to do this.