polly_dart
0.0.9, released 6 months ago by anirudhsingh.in
A Dart port of Polly for resilience and transient-fault handling like Retry and Circuit Breaker.
WASM-ready
What it does
Provides resilience strategies such as Retry, Circuit Breaker, Timeout, Rate Limiter, Hedging, and Fallback in a fluent and thread-safe manner. Allows developers to execute operations wrapped in robust resilience pipelines.
AI-written summary of version 0.0.9, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to retry failing network or database operations with exponential backoff.
- You want to protect downstream services using a circuit breaker.
- You need to handle rate limiting, timeouts, and fallbacks cleanly.
Skip it when
- Your application is entirely local and does not deal with transient failures or external APIs.
- You only need basic try-catch blocks for straightforward error handling.
Strengths
- Comprehensive feature set mirroring .NET Polly resilience strategies.
- Fluent builder API for creating custom resilience pipelines.
- Supports multiple strategies like Retry, Circuit Breaker, Hedging, and Rate Limiter.
Weaknesses
- Adds an extra layer of abstraction to asynchronous operations.
- Requires careful tuning of strategy parameters like delays and failure ratios.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:polly_dart/polly_dart.dart';
final pipeline = ResiliencePipelineBuilder()
.addRetry(RetryStrategyOptions(maxRetryAttempts: 3))
.addTimeout(Duration(seconds: 10))
.build();
final result = await pipeline.execute((context) async {
return await someAsyncOperation();
});Alternatives
Packages that do the same job and could replace polly_dart.
- rate_limiter
Apply rate limiting strategies like debounce, throttle, and backoff to regular Dart functions.
76Compare - zxcvbn
Dart port of Dropbox's zxcvbn password strength estimator library.
50Compare