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() }
}Content copied to clipboard