Skip to content

Feature: Policy Composition & Chaining API #29

@cinar

Description

@cinar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions