retrying

inline fun <T : Any> CoroutineScope.retrying(interval: Duration, name: String = "data", maxRetries: Int = Int.MAX_VALUE, start: CoroutineStart = CoroutineStart.DEFAULT, crossinline producer: suspend CoroutineScope.() -> T): RetryingJob<T>

Retries a suspending function producer up to maxRetries times with a delay of interval between each retry.

Return

A RetryingJob object.

Parameters

interval

The delay between each retry.

name

The name of the data being retried. Default is "data". Used for debug.

maxRetries

The maximum number of retries. Default is Int.MAX_VALUE.

start

The coroutine start mode of producer job. Default is CoroutineStart.DEFAULT.

producer

The suspending function to retry. If it throws a Throwable, it will be retried up to maxRetries times.