Namespace Kevlar
Classes
- Backoff
Computes the delay before each retry attempt. Create instances through the static factories.
- CircuitBreakerMonitor
Observes and manually controls one or more circuit breakers. Create one, assign it to each Monitor to control, and keep a reference to it.
- CircuitBreakerOptions
Configuration for a circuit breaker strategy. Configure either ConsecutiveFailures (simple mode) or FailureRatio (sampling mode). When neither is set, the breaker trips after 5 consecutive failures.
- CircuitBreakerOptions<TResult>
Result-typed configuration for a circuit breaker strategy on a Shield<TResult>.
- CircuitOpenException
Thrown when a circuit breaker rejects an execution because the circuit is open.
- ConcurrencyLimitExceededException
Thrown when a concurrency limit strategy rejects an execution because both the concurrency and queue limits are full.
- ConcurrencyLimitOptions
Configuration for a concurrency limit (concurrency limiter) strategy: at most MaxConcurrency executions run at once, with up to QueueLimit more waiting; anything beyond that is rejected immediately.
- ExecutionRejectedException
Base class for executions rejected by a Kevlar strategy.
- FallbackOptions
Configures notifications for an untyped fallback strategy.
- FallbackOptions<TResult>
Configures result-typed notifications for a fallback strategy on a Shield<TResult>.
- HedgeOptions
Configuration for a hedging strategy: launch up to MaxHedgedAttempts additional attempts, staggered by Delay, and return the first acceptable outcome. A handled failure always launches the next attempt immediately.
- HedgeOptions<TResult>
Result-typed configuration for a hedging strategy on a Shield<TResult>.
- KevlarConfigurationException
Represents invalid strategy configuration supplied through an options callback.
- KevlarContext
Ambient state for a single execution flowing through a shield pipeline. Contexts are created and pooled by Kevlar automatically; user code observes them in strategy callbacks or context-aware execution delegates and never needs to construct or return them. A context is valid only during the current callback or delegate invocation and must never be retained.
- KevlarDiagnostics
Names for Kevlar's built-in telemetry. On .NET 8+ targets every shield publishes counters and duration metrics; the shipped state gauges require .NET 10 or later. Metrics are published through a
System.Diagnostics.Metrics.Meternamed MeterName with zero configuration — subscribe withAddMeter("Kevlar")(OpenTelemetry) or aMeterListener. Onnetstandard2.0the instruments are inert.
- KevlarException
Base class for exceptions raised by Kevlar strategies themselves.
- KevlarKeys
Well-known property keys consumed by Kevlar integrations.
- KevlarMetricEnricher
Adds application-defined tags to Kevlar metric measurements.
- KevlarProperties
A strongly typed property bag carried by KevlarContext for passing custom data between the caller, execution delegate, and strategy callbacks. The bag is pooled with its context and must not be retained beyond the current callback or delegate. A completion callback receives this same live bag immediately before it is recycled; copy required values into caller-owned state rather than retaining the bag.
- KevlarProxyException
Base class for adapter-owned exceptions that preserve transport bookkeeping while exposing the original failure to Kevlar's handling clauses and public outcomes.
- PartitionedShieldOptions<TKey>
Controls retention for an untyped partitioned shield provider.
- PartitionedShieldOptions<TKey, TResult>
Controls retention for a result-aware partitioned shield provider.
- PartitionedShield<TKey>
Selects and retains an independent untyped Shield for each partition key.
- PartitionedShield<TKey, TResult>
Selects and retains an independent result-aware Shield<TResult> for each partition key.
- RateLimitExceededException
Thrown when a rate limit strategy rejects an execution.
- RateLimitOptions
Configuration for a token-bucket rate limit strategy: Permits executions per Window, with bursts up to Burst and optional queueing.
- RetryOptions
Configuration for a retry strategy.
- RetryOptions<TResult>
Result-typed configuration for a retry strategy on a Shield<TResult>: the events carry a typed Outcome<T> instead of a boxed object result.
- Shield
An immutable, thread-safe resilience pipeline. Build one once — with the static factories and fluent chaining — and reuse it for every execution. The first strategy in a chain is the outermost, exactly like ASP.NET middleware:
Shield.Timeout(t).Retry(3)applies a total timeout around all retries.
- ShieldBuilder
An immutable exception-handling clause under construction for a Shield chain. Obtained via
Shield.When<T>()orshield.When<T>(); finished by adding a strategy. The clause becomes the shield's ambient handling: it applies to the strategy added here and to reactive strategies chained afterwards, until replaced by a new clause.
- ShieldBuilder<TResult>
An immutable exception and result handling clause under construction for a Shield<TResult> chain. Obtained via the
When/WhenResultmethods on Shield<TResult> and finished by adding a strategy. The clause becomes the shield's ambient handling for the strategy added here and reactive strategies chained afterwards.
- ShieldExtensions
Fluent chaining for Shield. Each call returns a new immutable shield with the strategy appended; the earliest strategy in a chain is the outermost at execution time.
- ShieldResultExtensions
Result-handling clauses for Shield<TResult> chains whose result is a reference type. They are extension methods because only an extension method can constrain
TResult: a method declared on Shield<TResult> itself inherits whatever the shield was built for, so a null clause written there would compile forinttoo.
- ShieldTaskExtensions
Task-based execution overloads. Most application code returns Task<TResult> rather than ValueTask<TResult>; these overloads let such delegates flow straight into a shield:
shield.ExecuteAsync(ct => LoadUserAsync(id, ct)).
- Shield<TResult>
An immutable, thread-safe, result-aware resilience pipeline for executions returning
TResult. Unlike Shield, its handling clauses can react to result values (WhenResult) as well as exceptions. The first strategy in a chain is the outermost.
- Strategy
Base class for resilience strategies. A strategy is middleware: it receives a Continuation<T, TState> representing the rest of the pipeline and may invoke it zero, one or many times.
- TimeoutExceededException
Thrown when a timeout strategy cancels an execution that exceeded its allotted time.
- TimeoutOptions
Configuration for a timeout strategy.
Structs
- CallbackErrorEvent
Describes an exception thrown by an isolated callback or cleanup operation.
- CircuitBreakerBreakDurationEvent
Describes the handled outcome that is about to open a circuit.
- CircuitBreakerBreakDurationEvent<TResult>
Describes the typed handled outcome that is about to open a circuit.
- CircuitBreakerStateChangedEvent
Describes a circuit breaker state transition.
- ConcurrencyLimitRejectedEvent
Describes an execution rejected by the built-in concurrency limiter.
- Continuation<T, TState>
The rest of a shield pipeline, from a strategy's point of view. Invoking it runs every remaining strategy and finally the user's delegate. It may be invoked multiple times (retries, hedging) and with a forked context (hedging).
- FallbackEvent
Describes an exception being replaced by an untyped fallback.
- FallbackEvent<TResult>
Describes an outcome being replaced by a fallback.
- HandlingClause
Decides whether an outcome is a handled failure. Custom reactive strategies receive the active clause through a
Usefactory and should consult it instead of duplicating filters.
- HandlingEvent
Context supplied to an exception handling predicate.
- HandlingEvent<TResult>
Context supplied to a result-aware handling predicate.
- HedgeActionGeneratorEvent
Arguments used to select a void-returning operation for a hedged attempt.
- HedgeActionGeneratorEvent<TResult>
Arguments used to select a result-returning operation for a hedged attempt.
- HedgeDelayEvent
Describes an additional hedged attempt whose stagger delay is being selected.
- HedgeEvent
Describes a hedged attempt being launched.
- HedgeEvent<TResult>
Describes a hedged attempt being launched, with the latest handled outcome typed as
TResult.
- KevlarKey<T>
A strongly typed key for storing values in KevlarProperties.
- KevlarMetricEnrichmentContext
Provides callback-scoped information for a Kevlar metric measurement.
- KevlarTelemetryEvent
Describes one synchronous event emitted by a Kevlar strategy.
- Outcome
The result of a void execution: either success or a captured exception.
- Outcome<T>
The result of an execution: either a value or a captured exception, never both. Kevlar strategies pass outcomes between pipeline layers instead of throwing, so exceptions only pay their cost once, at the pipeline boundary.
- PartitionCreatedEvent<TKey>
Describes a newly created partition.
- PartitionCreatedEvent<TKey, TResult>
Describes a newly created result-aware partition.
- PartitionEvictedEvent<TKey>
Describes a partition removed from a provider.
- PartitionEvictedEvent<TKey, TResult>
Describes a result-aware partition removed from a provider.
- RateLimitRejectedEvent
Describes an execution rejected by the built-in rate limiter.
- RetryEvent
Describes a retry that is about to happen.
- RetryEvent<TResult>
Describes a retry that is about to happen, with the handled outcome typed as
TResult.
- TimeoutEvent
Provides execution context and duration for timeout callbacks.
Interfaces
- IKevlarTelemetryListener
Receives synchronous strategy telemetry without changing execution outcomes.
- IShieldDecorator
Decorates shields created by dependency-injection and HTTP integrations.
Enums
- BackoffKind
The built-in and caller-defined backoff categories.
- CallbackErrorKind
Identifies an isolated callback or cleanup failure reported by Kevlar.
- CircuitState
The state of a circuit breaker.
- Jitter
Controls randomization applied to built-in retry backoff delays.
- KevlarTelemetrySeverity
Classifies the operational significance of a Kevlar telemetry event.
- PartitionEvictionReason
Identifies why a partition was removed from a provider.