ResilientDeadline

A CoroutineContext element that carries a deadline for resilient policy execution.

When present in the coroutine context, the com.santimattius.resilient.composition.resilient builder will enforce this deadline on every execute call. If the deadline has already expired when execute is invoked, a kotlinx.coroutines.TimeoutCancellationException is thrown immediately without invoking the block. If both an explicit timeout { } and a deadline are configured, the shorter of the two wins.

Usage:

withContext(ResilientDeadline.after(5.seconds)) {
policy.execute { callRemoteService() }
}

Constructors

Link copied to clipboard
constructor(deadline: TimeMark)

Types

Link copied to clipboard

Properties

Link copied to clipboard

A TimeMark that represents the point in time at which the deadline expires. Created via after which sets it to now + duration.

Link copied to clipboard
open override val key: CoroutineContext.Key<*>

Functions

Link copied to clipboard
open override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
Link copied to clipboard
open operator override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
Link copied to clipboard
open override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
Link copied to clipboard
open operator fun plus(context: CoroutineContext): CoroutineContext
Link copied to clipboard

Returns the time remaining until the deadline expires.