Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (core) Add circuit breaker pattern for database operations -… #812

Merged

Conversation

augchan42
Copy link
Contributor

Related to #719

Fixes #712

This PR implements the circuit breaker pattern directly in DatabaseAdapter as discussed in the previous PR.

Implements circuit breaker pattern to handle database failures gracefully and prevent cascading failures. Fixes #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.

@augchan42 augchan42 changed the title feature: (core) Add circuit breaker pattern for database operations -… feat: (core) Add circuit breaker pattern for database operations -… Dec 3, 2024
@augchan42
Copy link
Contributor Author

augchan42 commented Dec 3, 2024 via email

@shakkernerd
Copy link
Member

It's fine.
Thanks for the work done!

Copy link
Member

@shakkernerd shakkernerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go!

@shakkernerd shakkernerd merged commit 438c1f1 into elizaOS:main Dec 3, 2024
3 checks passed
dsldsl pushed a commit to dsldsl/eliza that referenced this pull request Dec 7, 2024
…-pattern-v2

feat: (core) Add circuit breaker pattern for database operations -…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Add circuit breaker pattern for database operations
2 participants