Class HttpRetrySettings

java.lang.Object
com.helger.phase4.http.HttpRetrySettings

@NotThreadSafe public class HttpRetrySettings extends Object
An object encapsulating the HTTP retry settings. By default retries are disabled.
Since:
0.13.0
Author:
Philip Helger
  • Field Details

    • DEFAULT_MAX_RETRIES

      public static final int DEFAULT_MAX_RETRIES
      See Also:
    • DEFAULT_RETRY_DURATION

      public static final Duration DEFAULT_RETRY_DURATION
    • DEFAULT_RETRY_INCREASE_FACTOR

      public static final BigDecimal DEFAULT_RETRY_INCREASE_FACTOR
  • Constructor Details

    • HttpRetrySettings

      public HttpRetrySettings()
  • Method Details

    • isRetryEnabled

      public boolean isRetryEnabled()
      Returns:
      true if retries are enabled, false if not. Only if true is returned further calls to getMaxRetries(), getDurationBeforeRetry() and getRetryIncreaseFactor() 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

      @Nonnull public final HttpRetrySettings setMaxRetries(int nMaxRetries)
      Set the maximum number of retries.
      Parameters:
      nMaxRetries - New maximum. Any value ≤ 0 means "no retries".
      Returns:
      this for chaining
    • getDurationBeforeRetry

      @Nonnull public final Duration getDurationBeforeRetry()
      Returns:
      The duration before the first retry. Never null. The caller needs to ensure to increase the duration with the factor provided from getRetryIncreaseFactor(). The getIncreased(Duration, BigDecimal) utility method may be used to perform the necessary increase.
      See Also:
    • setDurationBeforeRetry

      @Nonnull public final HttpRetrySettings setDurationBeforeRetry(@Nonnull Duration aDurationBeforeRetry)
      Set the duration before the first retry.
      Parameters:
      aDurationBeforeRetry - The duration to use. May not be null.
      Returns:
      this for chaining
    • getRetryIncreaseFactor

      @Nonnull @Nonnegative public final BigDecimal 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

      @Nonnull public final 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 be null and must be > 0.
      Returns:
      this for chaining
    • getIncreased

      @Nonnull public static Duration getIncreased(@Nonnull Duration aDuration, @Nonnull BigDecimal aRetryIncreaseFactor)
    • assignFrom

      public final void assignFrom(@Nonnull HttpRetrySettings aOther)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object