Package io.smallrye.mutiny.helpers
Class ExponentialBackoff
- java.lang.Object
-
- io.smallrye.mutiny.helpers.ExponentialBackoff
-
public class ExponentialBackoff extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_JITTERstatic java.time.DurationMAX_BACKOFF
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.function.Function<Multi<java.lang.Throwable>,org.reactivestreams.Publisher<java.lang.Long>>randomExponentialBackoffFunction(long numRetries, java.time.Duration firstBackoff, java.time.Duration maxBackoff, double jitterFactor, java.util.concurrent.ScheduledExecutorService executor)Computes a method that would delay ticks using an exponential backoff.static java.util.function.Function<Multi<java.lang.Throwable>,org.reactivestreams.Publisher<java.lang.Long>>randomExponentialBackoffFunctionExpireAt(long expireAt, java.time.Duration firstBackoff, java.time.Duration maxBackoff, double jitterFactor, java.util.concurrent.ScheduledExecutorService executor)Computes a method that would delay ticks using an exponential backoff.
-
-
-
Field Detail
-
MAX_BACKOFF
public static final java.time.Duration MAX_BACKOFF
-
DEFAULT_JITTER
public static final double DEFAULT_JITTER
- See Also:
- Constant Field Values
-
-
Method Detail
-
randomExponentialBackoffFunction
public static java.util.function.Function<Multi<java.lang.Throwable>,org.reactivestreams.Publisher<java.lang.Long>> randomExponentialBackoffFunction(long numRetries, java.time.Duration firstBackoff, java.time.Duration maxBackoff, double jitterFactor, java.util.concurrent.ScheduledExecutorService executor)
Computes a method that would delay ticks using an exponential backoff.- Parameters:
numRetries- the max number of retriesfirstBackoff- the delay of the first backoffmaxBackoff- the max backoffjitterFactor- the jitter factor in [0, 1]executor- the executor used for the delay- Returns:
- the function
-
randomExponentialBackoffFunctionExpireAt
public static java.util.function.Function<Multi<java.lang.Throwable>,org.reactivestreams.Publisher<java.lang.Long>> randomExponentialBackoffFunctionExpireAt(long expireAt, java.time.Duration firstBackoff, java.time.Duration maxBackoff, double jitterFactor, java.util.concurrent.ScheduledExecutorService executor)
Computes a method that would delay ticks using an exponential backoff. Will keep retrying until an expiration time. The last attempt will start before the expiration time.- Parameters:
expireAt- absolute time in millis that specifies when to give up.firstBackoff- the delay of the first backoffmaxBackoff- the max backoffjitterFactor- the jitter factor in [0, 1]executor- the executor used for the delay- Returns:
- the function
-
-