Description
Currently, resile uses a fixed execution order (Circuit Breaker -> Adaptive Bucket -> Retry Loop). This issue proposes a flexible Policy Composition API that allows users to define the order of resilience layers.
Requirements
- Introduce a
Policy type that can be instantiated with multiple resilience strategies.
- Allow users to define the order of execution (e.g.,
Bulkhead -> Timeout -> CircuitBreaker -> Retry).
- Ensure the
Policy object is thread-safe and reusable.
- Refactor internal execution logic to be modular (middleware/interceptor pattern).
- Provide a
Do and DoErr method on the Policy object.
Proposed API
standardPolicy := resile.NewPolicy(
resile.WithBulkhead(20),
resile.WithCircuitBreaker(cb),
resile.WithRetry(3),
resile.WithFallback(func(...) { ... }),
)
// Reusable across multiple calls
val, err := standardPolicy.Do(ctx, action)
Reference
Description
Currently,
resileuses a fixed execution order (Circuit Breaker -> Adaptive Bucket -> Retry Loop). This issue proposes a flexible Policy Composition API that allows users to define the order of resilience layers.Requirements
Policytype that can be instantiated with multiple resilience strategies.Bulkhead -> Timeout -> CircuitBreaker -> Retry).Policyobject is thread-safe and reusable.DoandDoErrmethod on thePolicyobject.Proposed API
Reference