Package discord4j.common.retry
Class ReconnectOptions
java.lang.Object
discord4j.common.retry.ReconnectOptions
A configuration object to customize the gateway reconnection policy.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ReconnectOptions.Builder
builder()
Create a new builder forReconnectOptions
.static ReconnectOptions
create()
Create a defaultReconnectOptions
.Deprecated.only select implementations will use this value.Returns a scheduler provided every reconnect attempt, as backoff delay.Return the minimum backoff duration.Deprecated.only select implementations will use this value.double
Retrieve the jitter factor to be applied on each backoff delay.Return the maximum backoff duration.long
Returns the number of retries.
-
Field Details
-
DEFAULT_BACKOFF_SCHEDULER
-
-
Constructor Details
-
ReconnectOptions
-
-
Method Details
-
create
Create a defaultReconnectOptions
.- Returns:
- a new reconnect options configured with all defaults
-
builder
Create a new builder forReconnectOptions
.- Returns:
- a new builder
-
getFirstBackoff
Return the minimum backoff duration.- Returns:
- minimum backoff 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.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.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
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
and1d
-