PollingConfig

data class PollingConfig<T>(val fetch: suspend () -> PollingResult<T>, val isTerminalSuccess: (T) -> Boolean, val shouldRetryOnError: (Error?) -> Boolean = { true }, val backoff: BackoffPolicy = BackoffPolicy(), val dispatcher: CoroutineDispatcher = Dispatchers.Default, val onAttempt: (attempt: Int, delayMs: Long?) -> Unit = { _, _ -> }, val onResult: (attempt: Int, result: PollingResult<T>) -> Unit = { _, _ -> }, val onComplete: (attempts: Int, durationMs: Long, outcome: PollingOutcome<T>) -> Unit = { _, _, _ -> }, val throwableMapper: (Throwable) -> Error = { t -> val msg = t.message ?: (t::class.simpleName ?: "Throwable") // Use a stable public default code without exposing internal ErrorCodes Error(-1, msg) })

Configuration for the polling engine.

Constructors

Link copied to clipboard
constructor(fetch: suspend () -> PollingResult<T>, isTerminalSuccess: (T) -> Boolean, shouldRetryOnError: (Error?) -> Boolean = { true }, backoff: BackoffPolicy = BackoffPolicy(), dispatcher: CoroutineDispatcher = Dispatchers.Default, onAttempt: (attempt: Int, delayMs: Long?) -> Unit = { _, _ -> }, onResult: (attempt: Int, result: PollingResult<T>) -> Unit = { _, _ -> }, onComplete: (attempts: Int, durationMs: Long, outcome: PollingOutcome<T>) -> Unit = { _, _, _ -> }, throwableMapper: (Throwable) -> Error = { t -> val msg = t.message ?: (t::class.simpleName ?: "Throwable") // Use a stable public default code without exposing internal ErrorCodes Error(-1, msg) })

Properties

Link copied to clipboard
Link copied to clipboard
val dispatcher: CoroutineDispatcher
Link copied to clipboard
val fetch: suspend () -> PollingResult<T>
Link copied to clipboard
Link copied to clipboard
val onAttempt: (attempt: Int, delayMs: Long?) -> Unit
Link copied to clipboard
val onComplete: (attempts: Int, durationMs: Long, outcome: PollingOutcome<T>) -> Unit
Link copied to clipboard
val onResult: (attempt: Int, result: PollingResult<T>) -> Unit
Link copied to clipboard
Link copied to clipboard

Maps any thrown exception into a domain Error used by retry predicates and reporting.