V7 Compatibility
Polly v8 maintains full backward compatibility with v7 through the main Polly NuGet package. This allows you to upgrade to v8 and migrate your code gradually without breaking existing functionality.Understanding the Package Structure
Polly v8 introduces a new package structure to support both the new v8 APIs and legacy v7 APIs:Polly.Core Package
ThePolly.Core package contains only the new v8 resilience pipeline APIs. This is the recommended package for new applications or after you have fully migrated from v7 to v8.
Features:
- New resilience pipeline API
- Resilience strategies (retry, circuit breaker, timeout, etc.)
- Built-in telemetry
- Enhanced performance
- No legacy v7 APIs
Polly Package
ThePolly package includes everything from Polly.Core plus all the v7 policy APIs. This package is designed for migration scenarios.
Features:
- Everything from
Polly.Core - Full v7 policy API (
IAsyncPolicy,ISyncPolicy, etc.) - Interoperability between v7 and v8 APIs
- Backward compatibility with existing v7 code
The v7 API is still available and fully supported even when using the v8 version by referencing the Polly package.
Migration Strategy
When migrating from v7 to v8, follow this recommended approach:Step 1: Upgrade to Polly 8.x
Upgrade your NuGet package reference from Polly 7.x to Polly 8.x:Step 2: Migrate Gradually
Migrate your v7 policies to v8 strategies one at a time. Test each migration thoroughly before moving to the next.Step 3: Switch to Polly.Core
Once you have successfully migrated all your v7 policies to v8 strategies, switch from thePolly package to Polly.Core:
Interoperability Features
ThePolly package provides extension methods that enable interoperability between v7 policies and v8 resilience pipelines.
Converting Resilience Pipelines to Policies
You can convert v8 resilience pipelines to v7 policies using theAsSyncPolicy() and AsAsyncPolicy() extension methods:
Mixing v7 and v8 APIs
You can mix v7 policies and v8 resilience pipelines in the same application:When to Use Which Package
Use Polly Package When:
- You are migrating from v7 to v8
- You have existing v7 policies in your codebase
- You need interoperability between v7 and v8 APIs
- You want to upgrade to v8 without breaking changes
Use Polly.Core Package When:
- You are starting a new project
- You have fully migrated all v7 policies to v8 strategies
- You don’t need any v7 API compatibility
- You want the smallest package footprint
Key Differences to Understand
While thePolly package maintains backward compatibility, it’s important to understand the key differences between v7 and v8:
API Philosophy
- v7 Philosophy
- v8 Philosophy
- Static factory methods (
Policy.Handle<>(),Policy.Timeout(), etc.) - Separate sync and async policies
- Policy wrapping for composition
- Direct context passing
Terminology
| v7 Term | v8 Term |
|---|---|
| Policy | Strategy |
| Policy Wrap | Resilience Pipeline |
IAsyncPolicy / ISyncPolicy | ResiliencePipeline |
Context | ResilienceContext |
| Policy Registry | Resilience Pipeline Registry |
Feature Comparison
| Feature | v7 | v8 |
|---|---|---|
| Retry | ✅ | ✅ |
| Circuit Breaker | ✅ | ✅ (Advanced only) |
| Timeout | ✅ | ✅ (Optimistic only) |
| Bulkhead | ✅ | ✅ (As Concurrency Limiter) |
| Rate Limiter | ✅ | ✅ (Uses System.Threading.RateLimiting) |
| Fallback | ✅ | ✅ |
| Cache | ✅ | ✅ |
| Hedging | ❌ | ✅ |
| Built-in Telemetry | ❌ | ✅ |
| Chaos Engineering | Limited | ✅ (Polly.Testing) |
Common Migration Scenarios
Scenario 1: Web API with Retry and Circuit Breaker
Scenario 2: Using Dependency Injection
Benefits of Migrating to v8
While v7 compatibility is maintained, migrating to v8 provides several benefits:Performance Improvements
- Context pooling reduces allocations
- Zero-allocation APIs for high-performance scenarios
- Optimized execution paths for common scenarios
Enhanced Features
- Built-in telemetry with OpenTelemetry support
- Hedging strategy for parallel execution
- Chaos engineering support via Polly.Testing
- Dynamic pipeline configuration with hot reloading
Better Developer Experience
- Unified sync/async execution with single pipeline
- Options-based configuration for better IntelliSense
- Improved type safety with generic builders
- Better testability with dependency injection support
Additional Resources
- V8 Migration Guide - Complete migration guide with code examples
- Resilience Pipelines - Understanding the new pipeline architecture
- Resilience Strategies - Overview of all available strategies
- Dependency Injection - Using Polly v8 with DI
Support
If you encounter issues during migration:- Check the Migration Guide for specific scenarios
- Review the GitHub Discussions for community support
- Report bugs via GitHub Issues
The v7 API will continue to be supported in the
Polly package for the foreseeable future, allowing you to migrate at your own pace.