sm_retry library
Retry asynchronous functions with exponential backoff.
For a simple solution see retry, to modify and persist retry options see RetryOptions. Note, in many cases the added configurability is unnecessary and using retry is perfectly fine.
Classes
- RetryOptions
- Object holding options for retrying a function.
Functions
-
retry<
T> (FutureOr< T> fn(), {Duration delayFactor = const Duration(milliseconds: 200), double randomizationFactor = 0.25, Duration maxDelay = const Duration(seconds: 30), int maxAttempts = 8, RetryFunction<bool> ? retryIf, RetryFunction<void> ? onRetry, Duration? timeLimit, TimeoutCallback<T> ? onTimeout, bool lastTry = true}) → Future<T> -
Call
fnretrying so long asretryIfreturntruefor the exception thrown, up-tomaxAttemptstimes.
Typedefs
-
RetryFunction<
T> = FutureOr< T> Function(Exception e, int attempt) -
A function that returns
Tif the function should be retried. -
TimeoutCallback<
T> = FutureOr< T> Function(int attempt, Duration elapsed) - Timeout callback function type.