Package com.helger.phase4.messaging.http
Class HttpRetrySettings
java.lang.Object
com.helger.phase4.messaging.http.HttpRetrySettings
An object encapsulating the HTTP retry settings. By default retries are disabled.
- Since:
- 0.13.0
- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidassignFrom(@NonNull HttpRetrySettings aOther) booleanfinal @NonNull Durationstatic @NonNull DurationgetIncreased(@NonNull Duration aDuration, @NonNull BigDecimal aRetryIncreaseFactor) final intfinal @NonNull BigDecimalinthashCode()booleanfinal @NonNull HttpRetrySettingssetDurationBeforeRetry(@NonNull Duration aDurationBeforeRetry) Set the duration before the first retry.final @NonNull HttpRetrySettingssetMaxRetries(int nMaxRetries) Set the maximum number of retries.final @NonNull HttpRetrySettingssetRetryIncreaseFactor(@NonNull BigDecimal aRetryIncreaseFactor) Set the retry increase factor to use. 1 means no increase. 2 means the waiting time doubles every time.toString()
-
Field Details
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIES- See Also:
-
DEFAULT_RETRY_DURATION
-
DEFAULT_RETRY_INCREASE_FACTOR
-
-
Constructor Details
-
HttpRetrySettings
public HttpRetrySettings()
-
-
Method Details
-
isRetryEnabled
public boolean isRetryEnabled()- Returns:
trueif retries are enabled,falseif not. Only iftrueis returned further calls togetMaxRetries(),getDurationBeforeRetry()andgetRetryIncreaseFactor()make sense.
-
getMaxRetries
public final int getMaxRetries()- Returns:
- The maximum number of retries. Only if this value is > 0, retries are enabled.
- See Also:
-
setMaxRetries
Set the maximum number of retries.- Parameters:
nMaxRetries- New maximum. Any value ≤ 0 means "no retries".- Returns:
- this for chaining
-
getDurationBeforeRetry
- Returns:
- The duration before the first retry. Never
null. The caller needs to ensure to increase the duration with the factor provided fromgetRetryIncreaseFactor(). ThegetIncreased(Duration, BigDecimal)utility method may be used to perform the necessary increase. - See Also:
-
setDurationBeforeRetry
public final @NonNull HttpRetrySettings setDurationBeforeRetry(@NonNull Duration aDurationBeforeRetry) Set the duration before the first retry.- Parameters:
aDurationBeforeRetry- The duration to use. May not benull.- Returns:
- this for chaining
-
getRetryIncreaseFactor
- Returns:
- The retry increase factory, that should be applied for every retry after the first one.
Never
null. An increase factor of 1 means no increase. An increase factor of 2 means the waiting time doubles. The default is 1. Return values are always > 0.
-
setRetryIncreaseFactor
public final @NonNull HttpRetrySettings setRetryIncreaseFactor(@NonNull BigDecimal aRetryIncreaseFactor) Set the retry increase factor to use. 1 means no increase. 2 means the waiting time doubles every time. Only value > 0 are allowed.- Parameters:
aRetryIncreaseFactor- The retry increase factor. May not benulland must be > 0.- Returns:
- this for chaining
-
getIncreased
public static @NonNull Duration getIncreased(@NonNull Duration aDuration, @NonNull BigDecimal aRetryIncreaseFactor) -
assignFrom
-
equals
-
hashCode
public int hashCode() -
toString
-