suspend inline fun <T> attempt(maxAttempts: Int = 5, initialDelay: Long = 1000, maxDelay: Long = Long.MAX_VALUE, factor: Double = 1.0, logger: KLogger? = null, body: () -> T): T
A suspending function that makes multiple attempts to successfully execute a code block. Supports variable delays, logging and back off. The result of the computation on the first successful execution or the exception thrown on the last failing execution is propagated to the caller.
maxAttempts - The maximum number of attempts before failing.
initialDelay - The initial delay after the first failure.
maxDelay - The maximum amount of time to wait between attempts.
factor - The factor to increase the wait time by after each attempt.
logger - The logger to log attempt info to. No logging occurs if null.
body - The code body to attempt to run.
Throwable - Any exception that is thrown on the last attempt.
Return
The result of the computation.