This library is an exploratory implementation of the Circuit Breaker Pattern in Java, designed to improve system resilience by preventing cascading failures. It is not intended as a replacement for mature libraries like Resilience4j but serves as a research project that may be suitable for small to medium-sized applications where its specific design trade-offs are a good fit.
- State-driven Architecture: Follows a clear state machine (
CLOSE,OPEN,HALF_OPEN) for predictable behavior. - Centralized Management: A
CircuitBreakerRegistryto manage and access multiple circuit breaker instances in your application. - Modular Observation Strategies: Customize the behavior of each state with pluggable strategies.
- Sliding Window Close State Strategy: Monitors recent requests to decide when to trip the circuit based on failure rate or count.
- Time-based Open State Strategy: Keeps the circuit open for a configurable duration, allowing the downstream service time to recover.
- Count-based Half-Open State Strategy: Allows a limited number of trial requests to pass through to test if the downstream service has recovered.
- High-Performance Lock-Free Implementations: Each core strategy has a corresponding lock-free version designed for high-concurrency environments, minimizing contention and maximizing throughput.
- Rich Configuration: A fluent builder API for creating configurations, allowing you to tune every aspect of the circuit breaker's behavior.