Light on the hot path.
Struct outcomes, pooled contexts and ValueTask keep successful calls fast. State-passing overloads avoid closure allocations.
Dependencies fail. Your application doesn’t have to. Wrap every call in a little Kevlar.
Retries, circuit breakers, timeouts and more.
Seven strategies. One fluent shield API.
dotnet add package KevlarPick the protection your dependency needs. Chain strategies together into one reusable shield.
Give transient failures another chance.
Let struggling dependencies recover.
Keep every call within its budget.
Set a sustainable pace for requests.
Keep concurrent work under control.
Race another attempt against a slow call.
Have an answer when a dependency fails.
Compose your own protection.
Build a shield once. Reuse it across calls. Protection reads in execution order, from the outside in.
Timeout bounds the whole operation.
Retry adds backoff and jitter by default.
The circuit breaker stops repeated failures.
using Kevlar;
var shield = Shield
.Timeout(TimeSpan.FromSeconds(30))
.Retry(3)
.CircuitBreaker(
consecutiveFailures: 5,
breakDuration: TimeSpan.FromSeconds(30));
var user = await shield.ExecuteAsync(
ct => LoadUserAsync(id, ct), cancellationToken);
Struct outcomes, pooled contexts and ValueTask keep successful calls fast. State-passing overloads avoid closure allocations.
Shield.When<TimeoutExceededException>().Retry(3) says what you mean. Start with sensible defaults; fine-tune with options.
Targets netstandard2.0 and net10.0. NativeAOT-ready, with integrations for Microsoft DI and HttpClientFactory.