Class ReconnectOptions

java.lang.Object
discord4j.common.retry.ReconnectOptions

public class ReconnectOptions extends Object
A configuration object to customize the gateway reconnection policy.
  • Field Details

    • DEFAULT_BACKOFF_SCHEDULER

      public static final Supplier<Scheduler> DEFAULT_BACKOFF_SCHEDULER
  • Constructor Details

  • Method Details

    • create

      public static ReconnectOptions create()
      Create a default ReconnectOptions.
      Returns:
      a new reconnect options configured with all defaults
    • builder

      public static ReconnectOptions.Builder builder()
      Create a new builder for ReconnectOptions.
      Returns:
      a new builder
    • getFirstBackoff

      public Duration getFirstBackoff()
      Return the minimum backoff duration.
      Returns:
      minimum backoff duration
    • getMaxBackoffInterval

      public Duration getMaxBackoffInterval()
      Return the maximum backoff duration.
      Returns:
      maximum backoff duration
    • getMaxRetries

      public long getMaxRetries()
      Returns the number of retries.
      Returns:
      number of retries
    • getBackoff

      @Deprecated public Backoff getBackoff()
      Deprecated.
      only select implementations will use this value. Moving forward, consider assuming an exponential backoff function bounded by getFirstBackoff() and getMaxBackoffInterval()
      Retrieve the backoff function used for retrying. It uses a RetryContext object to calculate the correct backoff delay.
      Returns:
      a Backoff function
    • getJitter

      @Deprecated public Jitter getJitter()
      Deprecated.
      only select implementations will use this value. Moving forward, consider also using getJitterFactor()
      Retrieve the jitter to be applied on each backoff delay.
      Returns:
      a Jitter function
    • getBackoffScheduler

      public Scheduler getBackoffScheduler()
      Returns a scheduler provided every reconnect attempt, as backoff delay.
      Returns:
      scheduler used when reconnecting
    • getJitterFactor

      public double getJitterFactor()
      Retrieve the jitter factor to be applied on each backoff delay.
      Returns:
      a jitter factor value between 0d and 1d