retryPolicy

fun retryPolicy(scope: ResilientScope, maxAttempts: Int = 3, initialDelay: Duration = 10.milliseconds, maxDelay: Duration = 100.milliseconds, shouldRetry: (Throwable) -> Boolean = { true }): ResilientPolicy

Creates a ResilientPolicy with a retry policy configured for fast testing.

Default configuration:

  • maxAttempts = 3

  • backoffStrategy = ExponentialBackoff(initialDelay = 10ms, maxDelay = 100ms, factor = 2.0)

  • shouldRetry = { true } (retries all exceptions)

Return

A configured ResilientPolicy with retry.

Parameters

scope

The ResilientScope for the policy (typically a TestResilientScope).

maxAttempts

Maximum number of retry attempts. Default is 3.

initialDelay

Initial backoff delay. Default is 10ms.

maxDelay

Maximum backoff delay. Default is 100ms.

shouldRetry

Predicate to determine if an exception should trigger a retry. Default retries all.