ResilientScope
Manages a CoroutineScope for internal background tasks within resilience policies, such as cache cleanup (when com.santimattius.resilient.cache.CacheConfig.cleanupInterval is set).
The user's execution block passed to ResilientPolicy.execute runs in the caller's coroutine context, not in this scope. This scope is only used for policy-internal work (e.g. periodic sweeper jobs).
The internal scope uses a SupervisorJob, ensuring that the failure of one child coroutine does not affect others. Dispatchers.Default is used by default for CPU/background work.
As this class implements AutoCloseable, it can be used with use blocks for automatic resource management. Call close when the scope is no longer needed to cancel all running tasks and release resources.
Parameters
The CoroutineDispatcher for launching internal policy coroutines. Defaults to Dispatchers.Default.
Constructors
Functions
Launches a coroutine in this scope for internal policy work (e.g. cache cleanup).