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 class
ReconnectOptions.Builder
-
Field Summary
Fields Modifier and Type Field Description static Supplier<Scheduler>
DEFAULT_BACKOFF_SCHEDULER
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReconnectOptions(ReconnectOptions.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ReconnectOptions.Builder
builder()
Create a new builder forReconnectOptions
.static ReconnectOptions
create()
Create a defaultReconnectOptions
.Backoff
getBackoff()
Deprecated.only select implementations will use this value.Scheduler
getBackoffScheduler()
Returns a scheduler provided every reconnect attempt, as backoff delay.Duration
getFirstBackoff()
Return the minimum backoff duration.Jitter
getJitter()
Deprecated.only select implementations will use this value.double
getJitterFactor()
Retrieve the jitter factor to be applied on each backoff delay.Duration
getMaxBackoffInterval()
Return the maximum backoff duration.long
getMaxRetries()
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
0d
and1d
-
-