Package discord4j.common.retry
Class ReconnectOptions.Builder
- java.lang.Object
-
- discord4j.common.retry.ReconnectOptions.Builder
-
- Enclosing class:
- ReconnectOptions
public static class ReconnectOptions.Builder extends Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ReconnectOptions
build()
ReconnectOptions.Builder
setBackoff(Backoff backoff)
Deprecated.only select implementations will use this value.ReconnectOptions.Builder
setBackoffScheduler(Scheduler backoffScheduler)
Set theScheduler
to be used when building delayed sequences as backoff.ReconnectOptions.Builder
setFirstBackoff(Duration firstBackoff)
Set the firstDuration
to be applied when computing a backoff.ReconnectOptions.Builder
setJitter(Jitter jitter)
Deprecated.only select implementations will use this value.ReconnectOptions.Builder
setJitterFactor(double jitterFactor)
Set a jitter factor for exponential backoff that adds randomness to each backoff.ReconnectOptions.Builder
setMaxBackoffInterval(Duration maxBackoffInterval)
Set the maximumDuration
to be applied when computing a backoff.ReconnectOptions.Builder
setMaxRetries(long maxRetries)
Set the maximum number of iterations to retry before rethrowing the error as exhausted attempts.
-
-
-
Method Detail
-
setFirstBackoff
public ReconnectOptions.Builder setFirstBackoff(Duration firstBackoff)
Set the firstDuration
to be applied when computing a backoff. Defaults to 2 seconds.- Parameters:
firstBackoff
- the minimum duration to be applied as backoff- Returns:
- this builder
-
setMaxBackoffInterval
public ReconnectOptions.Builder setMaxBackoffInterval(Duration maxBackoffInterval)
Set the maximumDuration
to be applied when computing a backoff. Defaults to 30 seconds.- Parameters:
maxBackoffInterval
- the maximum duration to be applied as backoff- Returns:
- this builder
-
setMaxRetries
public ReconnectOptions.Builder setMaxRetries(long maxRetries)
Set the maximum number of iterations to retry before rethrowing the error as exhausted attempts. Defaults to Long.MAX_VALUE (unlimited retries).- Parameters:
maxRetries
- the maximum number of retries- Returns:
- this builder
-
setBackoff
@Deprecated public ReconnectOptions.Builder setBackoff(Backoff backoff)
Deprecated.only select implementations will use this value. Moving forward, consider assuming an exponential backoff function bounded byReconnectOptions.getFirstBackoff()
andReconnectOptions.getMaxBackoffInterval()
Set the backoff function given by reactor-extraBackoff
type. Defaults to an exponential backoff strategy that uses a context object for obtaining the actual iteration.- Parameters:
backoff
- a backoff function to apply on retries- Returns:
- this builder
-
setJitter
@Deprecated public ReconnectOptions.Builder setJitter(Jitter jitter)
Deprecated.only select implementations will use this value. Moving forward, consider usingsetJitterFactor(double)
}Set the jitter function given by reactor-extraJitter
type. Defaults to 50% randomness.- Parameters:
jitter
- a jitter function to apply on retries- Returns:
- this builder
-
setBackoffScheduler
public ReconnectOptions.Builder setBackoffScheduler(Scheduler backoffScheduler)
Set theScheduler
to be used when building delayed sequences as backoff. Defaults to dedicated parallel schedulerReconnectOptions.DEFAULT_BACKOFF_SCHEDULER
.- Parameters:
backoffScheduler
- a reactor scheduler used for backoff delays- Returns:
- this builder
-
setJitterFactor
public ReconnectOptions.Builder setJitterFactor(double jitterFactor)
Set a jitter factor for exponential backoff that adds randomness to each backoff. Defaults to0.5
(a jitter of at most 50% of the computed delay)- Parameters:
jitterFactor
- the new jitter factor as adouble
between0d
and1d
- Returns:
- this builder
-
build
public ReconnectOptions build()
-
-