Package kong.unirest.core
Class RetryStrategy.Standard
- java.lang.Object
-
- kong.unirest.core.RetryStrategy.Standard
-
- All Implemented Interfaces:
RetryStrategy
- Enclosing interface:
- RetryStrategy
public static class RetryStrategy.Standard extends java.lang.Object implements RetryStrategy
A standard implementation of the RetryStrategy which follows spec based Retry-After logic - Will attempt a retry on any 301, 429, 503, or 529 response which is accompanied by a Retry-After header. - Retry-After can be either date or seconds based see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface kong.unirest.core.RetryStrategy
RetryStrategy.Standard
-
-
Field Summary
Fields Modifier and Type Field Description private int
maxAttempts
private static java.lang.String
RETRY_AFTER
private static java.util.Set<java.lang.Integer>
RETRY_CODES
-
Constructor Summary
Constructors Constructor Description Standard(int maxAttempts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMaxAttempts()
Get the max number of times the Unirest should retry responses before giving up and allowing a final returnlong
getWaitTime(HttpResponse response)
Get the number of milliseconds the system should wait before retrying.boolean
isRetryable(HttpResponse response)
Checks to see if the response is retryableprivate static long
parse(java.lang.String s)
protected java.lang.Long
parseToMillies(java.lang.String value)
private static java.lang.Long
tryAsDateTime(java.lang.String value)
private static java.util.Optional<java.lang.Long>
trySeconds(java.lang.String s)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface kong.unirest.core.RetryStrategy
waitFor
-
-
-
-
Field Detail
-
RETRY_CODES
private static final java.util.Set<java.lang.Integer> RETRY_CODES
-
RETRY_AFTER
private static final java.lang.String RETRY_AFTER
- See Also:
- Constant Field Values
-
maxAttempts
private final int maxAttempts
-
-
Method Detail
-
isRetryable
public boolean isRetryable(HttpResponse response)
Description copied from interface:RetryStrategy
Checks to see if the response is retryable- Specified by:
isRetryable
in interfaceRetryStrategy
- Parameters:
response
- the last response- Returns:
- a bool indicating if the request should be retried
-
getWaitTime
public long getWaitTime(HttpResponse response)
Description copied from interface:RetryStrategy
Get the number of milliseconds the system should wait before retrying. A value less than 1 will result in the termination of the retry loop- Specified by:
getWaitTime
in interfaceRetryStrategy
- Parameters:
response
- the last response- Returns:
- millies
-
parseToMillies
protected java.lang.Long parseToMillies(java.lang.String value)
-
getMaxAttempts
public int getMaxAttempts()
Description copied from interface:RetryStrategy
Get the max number of times the Unirest should retry responses before giving up and allowing a final return- Specified by:
getMaxAttempts
in interfaceRetryStrategy
- Returns:
- the max attempts
-
tryAsDateTime
private static java.lang.Long tryAsDateTime(java.lang.String value)
-
trySeconds
private static java.util.Optional<java.lang.Long> trySeconds(java.lang.String s)
-
parse
private static long parse(java.lang.String s)
-
-