-
-
Notifications
You must be signed in to change notification settings - Fork 249
Add extensible resilience policies #388
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
Conversation
benchmarks/BenchmarkDotNet.Artifacts/Foundatio.Benchmarks.Benchmarks-20250630-100739.log
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces extensible resilience policies to Foundatio including a new ResiliencePolicyProvider, a ResiliencePolicy with fluent builder APIs, and updates across caching, queues, locks, messaging, storage, and jobs to integrate with the new resilience system.
- Added core resilience types and builder patterns for configuring retries, circuit breakers, timeouts, jitter, and custom exception filtering.
- Updated tests, benchmarks, and documentation to demonstrate and validate the new resilience functionality.
Reviewed Changes
Copilot reviewed 47 out of 49 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Foundatio.Tests/Utility/RunTests.cs | Removed obsolete tests for Run utility methods. |
| tests/Foundatio.Tests/Utility/ResiliencePolicyTests.cs | Updated tests to validate the new resilience policies. |
| tests/Foundatio.Tests/Utility/PollyResiliencePolicyProvider.cs | Added tests for the Polly-based policy wrapper integration. |
| tests/Foundatio.Tests/Queue/InMemoryQueueTests.cs | Increased timeout duration for queue tests to support resilience. |
| tests/Foundatio.Tests/Locks/InMemoryLockTests.cs | Updated lock provider constructor signature to include resilience. |
| ... | Numerous updates in caching, storage, messaging, jobs and benchmarks to use the new resilience interfaces. |
| README.md | Updated documentation with new Resilience section and samples. |
| benchmarks/* | Added benchmarks to compare performance of ResiliencePolicy vs Polly. |
🔧 Add Resilience Policy Provider Implementation
Overview
This PR introduces a new resilience policy provider implementation to Foundatio that allows end users to customize and replace how retries and resilience patterns are handled throughout the library. This provides a lightweight, high-performance alternative to external libraries like Polly while maintaining compatibility with existing resilience solutions.
Features Added
Core Implementation
Key Capabilities
Usage Examples
Basic Policy Setup
Named Policies for Different Scenarios
Circuit Breaker Configuration
Custom Retry Logic
Integration with Foundatio Components
The resilience policies integrate seamlessly with existing Foundatio components through the
IHaveResiliencePolicyProviderinterface:Performance Benchmarks
Our benchmarks show excellent performance characteristics compared to Polly:
The Foundatio implementation provides:
Breaking Changes
❌ None - This is a purely additive feature that doesn't modify any existing APIs.
Migration from Polly
For users currently using Polly, migration is straightforward:
Integration with External Resilience Libraries
The resilience policy provider design allows you to easily integrate with external libraries like Polly by implementing a custom
IResiliencePolicywrapper:This approach allows you to:
Advanced Features
Manual Circuit Breaker Control
Custom Exception Handling
Integration Points
The resilience policy provider is designed to integrate with:
Testing
The implementation includes comprehensive unit tests covering:
Documentation Updates
This resilience policy implementation provides Foundatio users with a high-performance, lightweight alternative for handling transient failures while maintaining the option to integrate with external resilience libraries when needed.