Package org.nuxeo.common.utils
Class RetryUtils
java.lang.Object
org.nuxeo.common.utils.RetryUtils
- Since:
- 2025.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TexponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot) static <T> TexponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot, Duration threshold) Tries at mosttryCounttimes to return the result of the givensupplier, if not null.
-
Method Details
-
exponentialBackoff
- See Also:
-
exponentialBackoff
public static <T> T exponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot, Duration threshold) Tries at mosttryCounttimes 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 giventimeSlotduration.If
thresholdis not null, then the waiting time doesn't exceed thethresholdduration: when the waiting time reachesthreshold, it is reset totimeSlot.- Throws:
RuntimeException- if the retry count was exceeded
-