Skip to content

Commit

Permalink
fix: (core) Add circuit breaker pattern for database operations
Browse files Browse the repository at this point in the history
Implements circuit breaker pattern to handle database failures gracefully
and prevent cascading failures. Fixes elizaOS#712.

Changes:
- Adds CircuitBreaker class with CLOSED, OPEN, and HALF-OPEN states
- Introduces BaseCircuitBreakerAdapter for database adapters
- Configurable failure thresholds and recovery timeouts
- Automatic recovery attempts in HALF-OPEN state
- Detailed logging of circuit breaker state changes

Circuit breaker configuration:
- Opens after 5 consecutive failures (configurable)
- Resets after 60 seconds in OPEN state
- Requires 3 successful operations in HALF-OPEN state to close

This helps prevent overwhelming failed database connections and provides
graceful degradation during outages.
  • Loading branch information
augchan42 committed Nov 30, 2024
1 parent 8c35b9e commit 58309eb
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 388 deletions.
Loading

0 comments on commit 58309eb

Please # to comment.