Package discord4j.common.retry
Class ReconnectOptions
- java.lang.Object
-
- discord4j.common.retry.ReconnectOptions
-
public class ReconnectOptions extends Object
A configuration object to customize the gateway reconnection policy.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReconnectOptions.Builder
-
Field Summary
Fields Modifier and Type Field Description static Supplier<Scheduler>DEFAULT_BACKOFF_SCHEDULER
-
Constructor Summary
Constructors Modifier Constructor Description protectedReconnectOptions(ReconnectOptions.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ReconnectOptions.Builderbuilder()Create a new builder forReconnectOptions.static ReconnectOptionscreate()Create a defaultReconnectOptions.BackoffgetBackoff()Deprecated.only select implementations will use this value.SchedulergetBackoffScheduler()Returns a scheduler provided every reconnect attempt, as backoff delay.DurationgetFirstBackoff()Return the minimum backoff duration.JittergetJitter()Deprecated.only select implementations will use this value.doublegetJitterFactor()Retrieve the jitter factor to be applied on each backoff delay.DurationgetMaxBackoffInterval()Return the maximum backoff duration.longgetMaxRetries()Returns the number of retries.
-
-
-
Constructor Detail
-
ReconnectOptions
protected ReconnectOptions(ReconnectOptions.Builder builder)
-
-
Method Detail
-
create
public static ReconnectOptions create()
Create a defaultReconnectOptions.- Returns:
- a new reconnect options configured with all defaults
-
builder
public static ReconnectOptions.Builder builder()
Create a new builder forReconnectOptions.- 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 bygetFirstBackoff()andgetMaxBackoffInterval()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 usinggetJitterFactor()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
0dand1d
-
-