Package org.nuxeo.common.utils
Class RetryUtils
- java.lang.Object
-
- org.nuxeo.common.utils.RetryUtils
-
public class RetryUtils extends Object
- Since:
- 2025.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
exponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot)
static <T> T
exponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot, Duration threshold)
Tries at mosttryCount
times to return the result of the givensupplier
, if not null.
-
-
-
Method Detail
-
exponentialBackoff
public static <T> T exponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot)
-
exponentialBackoff
public static <T> T exponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot, Duration threshold)
Tries at mosttryCount
times to return the result of the givensupplier
, if not null. The waiting time between each try is computed with an exponential backoff algorithm based on the giventimeSlot
duration.If
threshold
is not null, then the waiting time doesn't exceed thethreshold
duration: when the waiting time reachesthreshold
, it is reset totimeSlot
.- Throws:
RuntimeException
- if the retry count was exceeded
-
-