Class HttpRetryPolicy
- java.lang.Object
-
- org.datadog.jenkins.plugins.datadog.clients.HttpRetryPolicy
-
@NotThreadSafe public class HttpRetryPolicy extends Object
A policy which encapsulates retry rules for HTTP calls. Whether to retry and how long to wait before the next attempt is determined by received HTTP response.Logic is the following:
- if there was no response, or response code is 5XX, wait for specified delay time and retry (there is exponential backoff, so each consecutive retry takes longer than the previous one). Maximum number of retries and delay multiplication factor are provided during policy instantiation
- if response code is 429 (Too Many Requests), try to get wait time from
x-ratelimit-reset response header. Depending on the result:
- if time is less than 10 seconds, wait for the specified amount + random(0, 0.4sec) (there will be only one retry in this case)
- if time is more than 10 seconds, do not retry
- if time was not provided or could not be parsed, do a regular retry (same logic as for 5XX responses)
- in all other cases do not retry
Instances of this class are not thread-safe and not reusable: each HTTP call requires its own instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpRetryPolicy.Factory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
backoff()
boolean
shouldRetry(org.eclipse.jetty.client.api.Response response)
-