This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Carom is a high-performance, zero-dependency resilience library for .NET. It provides retry, timeout, circuit breaker, bulkhead, rate limiting, and fallback patterns with minimal allocations and lock-free implementations.
dotnet build # Build all projects
dotnet build -c Release # Build in Release mode
dotnet test # Run all tests
dotnet test --filter "FullyQualifiedName~CushionTests" # Run specific test class
dotnet test --filter "MethodName" # Run single test by method name
dotnet pack -c Release # Create NuGet packagescd benchmarks/Carom.Benchmarks
dotnet run -c Release # Run all benchmarks
dotnet run -c Release --filter *LightLoad* # Run specific category| Pattern | Class | Package |
|---|---|---|
| Retry + Timeout | Carom, Bounce |
Carom |
| Circuit Breaker | Cushion |
Carom.Extensions |
| Bulkhead | Compartment |
Carom.Extensions |
| Rate Limiting | Throttle |
Carom.Extensions |
| Fallback | Pocket/PocketAsync |
Carom.Extensions |
Each resilience pattern follows a consistent architecture:
- State class (e.g.,
CushionState,ThrottleState): Holds mutable state using lock-free Interlocked operations - Store class (e.g.,
CushionStore,ThrottleStore): Manages singleton instances per service/resource key - Builder pattern: Fluent API for configuration (e.g.,
Cushion.ForService("api").OpenAfter(...))
- Lock-free: All state updates use
Interlockedoperations, never locks - Zero allocations on hot path: Uses structs (
Bounce), thread-static Random, avoids closures - RingBuffer: Sliding window tracking for circuit breaker and rate limiter
- Decorrelated jitter: Mandatory exponential backoff with AWS-style jitter formula
- No LINQ in hot paths - Use
forloops - Zero allocations - Use
structandSpan<T> - Zero external dependencies in core packages
- Expression Trees over Reflection for meta-programming
- xUnit with plain
Assert, no assertion libraries - Benchmarks required for performance-critical changes (BenchmarkDotNet)
- License: MPL-2.0 headers on all source files
- Versioning: SemVer with manual bumps only
tests/Carom.Tests/- Core retry and timeout teststests/Carom.Extensions.Tests/- Circuit breaker, bulkhead, throttle, fallback tests- Test categories:
SmokeTests,EdgeCaseTests,SecurityTests(thread-safety)
src/
├── Carom/ # Core: Carom.cs, Bounce.cs, JitterStrategy.cs
├── Carom.Extensions/ # Cushion, Compartment, Throttle + Stores
├── Carom.Http/ # HttpClient integration
├── Carom.AspNetCore/ # Health checks
├── Carom.EntityFramework/ # EF Core retry
└── Carom.Telemetry.OpenTelemetry/ # Metrics