Class RetryPolicy
GET only.
Set it with Pain001Client.Builder.retryPolicy; without one the client sends every
request once. With one, a GET (health(), faces(), and request
with GET) is sent again after a connection failure or timeout, or an HTTP 429 or 503
answer, up to maxAttempts() times in all. A POST (validate,
generate, check, projectFace, and request with any other method) is
never retried.
The wait before retry n (from 1) is exponential with jitter: d = min(maxBackoff,
initialBackoff * 2^(n-1)), then a random point in [d/2, d]. A 429 or 503 answer with a
Retry-After header (seconds or an HTTP date) waits exactly that long instead; when it asks
for longer than maxBackoff() the client stops retrying and returns that answer rather
than retry early. The last attempt's answer or failure is what the call returns or raises.
Pain001Client client = Pain001Client.builder()
.baseUrl("http://127.0.0.1:8000")
.retryPolicy(RetryPolicy.builder().maxAttempts(4).build())
.build();
Instances are immutable and thread-safe.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic RetryPolicy.Builderbuilder()Starts a builder with the defaults: 3 attempts, 200 ms initial and 5 s maximum backoff.The wait before the first retry, before jitter.intThe number of attempts in all, including the first.The longest wait before any retry, and the longestRetry-Afterhonoured.
-
Method Details
-
builder
Starts a builder with the defaults: 3 attempts, 200 ms initial and 5 s maximum backoff.- Returns:
- a new builder
-
maxAttempts
public int maxAttempts()The number of attempts in all, including the first.- Returns:
- at least 1
-
initialBackoff
The wait before the first retry, before jitter.- Returns:
- a positive duration
-
maxBackoff
The longest wait before any retry, and the longestRetry-Afterhonoured.- Returns:
- a duration no shorter than
initialBackoff()
-