compositionOrder
Configures the order in which policies are composed. Policies are applied from outermost (first in list) to innermost (last in list).
Important: Fallback is always positioned outermost and cannot be included in the order. It will be automatically prepended to ensure it catches all failures from other policies.
Parameters
order
The list of orderable policy types in the desired composition order (outermost to innermost). Optional: may be empty or a subset. Types in the list are ordered as given; any type not in the list is appended in the default order. Duplicates are removed.
Example:
import com.santimattius.resilient.composition.OrderablePolicyType
resilient(scope) {
compositionOrder(listOf(
OrderablePolicyType.CACHE, // Check cache first (after Fallback)
OrderablePolicyType.TIMEOUT, // Then apply timeout
OrderablePolicyType.RETRY, // Retry on failures
OrderablePolicyType.CIRCUIT_BREAKER,
OrderablePolicyType.RATE_LIMITER,
OrderablePolicyType.BULKHEAD,
OrderablePolicyType.HEDGING
))
// Fallback is automatically added as the outermost policy
// ... configure policies
}Content copied to clipboard