Carom: Physics-based, zero-dependency resilience library for .NET. Enforces decorrelated jitter by default to prevent Thundering Herd issues. Includes retry with exponential backoff and timeout support. Lean, fast, and safe.
$ dotnet add package CaromA lean, fast, and safe resilience library for .NET
Carom is a zero-dependency resilience library that enforces best practices by default. Named after the billiards shot where the ball bounces before reaching its target, Carom helps your code gracefully handle failures.
| Package | Version | Size | Purpose |
|---|---|---|---|
| Carom | v1.3.0 | 13KB | Core retry + timeout |
| Carom.Extensions | v1.4.0 | 20KB | Circuit Breaker, Fallback, Bulkhead, Rate Limiting |
| Carom.Http | v1.0.0 | 11KB | HTTP integration |
| Carom.AspNetCore | v1.0.0 | 10KB | ASP.NET Core health checks |
| Carom.EntityFramework | v1.0.0 | 10KB | EF Core retry |
| Carom.Telemetry.OpenTelemetry | v1.0.0 | 9KB | OpenTelemetry metrics |
dotnet add package Carom
dotnet add package Carom.Extensions
using Carom;
// Simple retry with exponential backoff
var result = await Carom.ShotAsync(() => api.CallAsync(), retries: 3);
// With timeout
var bounce = Bounce.Times(5).WithTimeout(TimeSpan.FromSeconds(30));
var data = await Carom.ShotAsync(() => apiClient.FetchAsync(), bounce);
using Carom.Extensions;
var cushion = Cushion.ForService("payment-api")
.OpenAfter(failures: 5, within: 10)
.HalfOpenAfter(TimeSpan.FromSeconds(30));
var payment = await CaromCushionExtensions.ShotAsync(
() => paymentApi.Charge(),
cushion);
var config = await new Func<Task<AppConfig>>(() => configService.LoadAsync())
.PocketAsync(AppConfig.Default);
var dbCompartment = Compartment.ForResource("database")
.WithMaxConcurrency(10)
.Build();
var query = await CaromCompartmentExtensions.ShotAsync(
() => db.QueryAsync(sql),
dbCompartment);
var apiThrottle = Throttle.ForService("external-api")
.WithRate(100, TimeSpan.FromSeconds(1))
.WithBurst(20)
.Build();
var apiResult = await CaromThrottleExtensions.ShotAsync(
() => apiClient.CallAsync(),
apiThrottle);
| Pattern | Class | Purpose |
|---|---|---|
| Retry | Carom | Exponential backoff with jitter |
| Timeout | Bounce.WithTimeout() | Operation timeout |
| Circuit Breaker | Cushion | Prevent cascade failures |
| Fallback | Pocket/PocketAsync | Graceful degradation |
| Bulkhead | Compartment | Concurrency control |
| Rate Limiting | Throttle | Token bucket algorithm |
Contributions welcome! Please read our contributing guidelines first.
MPL-2.0 - see LICENSE for details.
Built with the Baryo.Dev philosophy: zero dependencies, minimal allocations, safe by default.
Made with ❤️ by Baryo.Dev
Carom is significantly faster than Polly v8:
See detailed benchmarks for complete analysis.