with Retries
suspend fun <T> suspend () -> ErrorOr<T>.withRetries(until: (ErrorOr<T>) -> Boolean = { it.isRight() }, additionalTimes: Int = 4, delay: Duration = Duration.ofMillis(20L), exponentialBackoff: Boolean = false, jitter: Boolean = false): ErrorOr<T>(source)
Retry a suspended supplier of an ErrorOr until a maximum number of times or a predicate has been fulfilled.
Parameters
until
the predicate that indicates success. Defaults to "no exceptions encountered".
additional Times
how many times to retry before giving up. Defaults to 4 (5 attempts in total).
delay
how long to delay between attempts. Defaults to 20ms.
exponential Backoff
if true, will double the delay on each attempt. Defaults to false.
jitter
if true, will stagger the attempts to reduce likelihood of collisions. Defaults to false.