Introduction to Polly Project
Polly is a robust .NET library designed to manage resilience and transient-fault situations effectively. For developers working within the .NET environment, Polly offers an expressive, fluent and thread-safe way to articulate resilience strategies such as Retry, Circuit Breaker, Hedging, Timeout, Rate Limiter, and Fallback.
Membership and Updates
Polly project is proudly a member of the .NET Foundation, which supports open-source projects in the .NET ecosystem. Staying updated with the latest features, tips, and news about Polly can be easily managed through thepollyproject.org.
Documentation and Compatibility
Polly's documentation comprehensively covers the latest version 8 API. However, if you are utilizing version 7, you should refer to the earlier documentation to ensure compatibility and correct usage.
NuGet Packages
Polly's core and advanced functionalities can be accessed through various NuGet packages:
Polly.Core
: Contains the essential components and predefined strategies that form the backbone of the Polly library.Polly.Extensions
: Provides added support for telemetry and dependency injection.Polly.RateLimiting
: Offers integration with specific APIs for managing rate limits effectively.Polly.Testing
: Facilitates testing practices for Polly's features.Polly
: This contains legacy APIs for those still operating on the older versions of the Polly library.
Getting Started
To deploy Polly in your project, you'll start by creating a resilience pipeline, which combines various resilience strategies for robust fault handling. To do this:
- Add the Polly.Core package to your project.
- Utilize the
ResiliencePipelineBuilder
to configure strategies like retries and timeouts according to your project needs.
Dependency Injection
For developers who prefer using dependency injection, Polly supports this approach through the Polly.Extensions
package, allowing seamless integration into your existing dependency injection setup.
Understanding Resilience Strategies
Polly categorizes resilience strategies into reactive and proactive types:
-
Reactive Strategies address specific exceptions or results:
- Retry: Handles transient faults by performing automatic retries.
- Circuit Breaker: Stops operations when failures exceed a threshold to protect systems from further harm.
- Fallback: Provides alternate strategies when operations fail.
- Hedging: Executes alternate operations in parallel for slow processes, utilizing the fastest result.
-
Proactive Strategies proactively manage execution conditions:
- Timeout: Ensures processes do not hang indefinitely by setting maximum wait times.
- Rate Limiter: Regulates the rate at which requests are processed to manage load efficiently.
Detailed configuration options and usage examples for each strategy can be found in the resilience strategies documentation.
Additional Features
Post Polly version 8.3, the library has integrated with Simmy to include chaos engineering capabilities, allowing developers to build resilience by intentionally introducing faults to observe and fix weaknesses.
Community and Support
Example applications and community contributions are encouraged to aid in learning Polly's capabilities, such examples can be found in the Polly-Samples repository. Interested developers can also see Polly in action in Microsoft's eShopOnContainers project.
Sponsorship
Thanks to sponsors like .NET on AWS Open Source Software Fund and Microsoft's Free and Open Source Software Fund, Polly continues its development and enhancement. Community support is welcome through GitHub Sponsors.
Polly stands as a powerful tool for developers seeking to enhance their applications' resilience, ensuring robust error handling and smooth operation even in unpredictable environments.