Innovabit.DotNet.Interceptors.Collections 3.0.128

There is a newer version of this package available.
See the version list below for details.
dotnet add package Innovabit.DotNet.Interceptors.Collections --version 3.0.128
                    
NuGet\Install-Package Innovabit.DotNet.Interceptors.Collections -Version 3.0.128
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Innovabit.DotNet.Interceptors.Collections" Version="3.0.128" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Innovabit.DotNet.Interceptors.Collections" Version="3.0.128" />
                    
Directory.Packages.props
<PackageReference Include="Innovabit.DotNet.Interceptors.Collections" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Innovabit.DotNet.Interceptors.Collections --version 3.0.128
                    
#r "nuget: Innovabit.DotNet.Interceptors.Collections, 3.0.128"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Innovabit.DotNet.Interceptors.Collections@3.0.128
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Innovabit.DotNet.Interceptors.Collections&version=3.0.128
                    
Install as a Cake Addin
#tool nuget:?package=Innovabit.DotNet.Interceptors.Collections&version=3.0.128
                    
Install as a Cake Tool

Innovabit.DotNet.Interceptors.Collections

A collection of ready-to-use interceptors for the Innovabit.DotNet.Interceptors suite. It provides retry-on-exception, timeout, circuit-breaker and fallback interceptors.

Install

dotnet add package Innovabit.DotNet.Interceptors.Collections

Retry on exception

Decorate a method with [RetryOnException] and it is retried when it throws.

using Innovabit.DotNet.Interceptors.Collections.Retries;

public class PaymentService : IPaymentService
{
    [RetryOnException(MaxFailures = 5, WaitMs = 200, ExceptionTypes = new[] { typeof(HttpRequestException) })]
    public Task ChargeAsync(Order order) { ... }
}

Register it from DI:

services.AddInterceptors()
    .AddRetry();

services.AddScopedWithInterception<IPaymentService, PaymentService>();

Options ([RetryOnException])

  • MaxFailures — maximum attempts (default 3, must be > 0).
  • WaitMs — delay between attempts in milliseconds (default 1000).
  • ExceptionTypes / ExceptionType — only retry for these exception types; when unset, any exception is retried.

Once the caller's CancellationToken (the method's own argument) is cancelled nothing more is attempted, and the wait between attempts ends early. A dependency that cancels on its own — an HTTP client's timeout — is still retried.

Works with synchronous methods, Task and Task<T>. When all attempts fail the last exception is re-thrown preserving its original stack trace.

Timeout

Decorate a method with [Timeout(milliseconds)] and it fails with a TimeoutException when it runs longer than the limit.

using Innovabit.DotNet.Interceptors.Collections.Timeouts;

public class ReportService : IReportService
{
    [Timeout(5000)]
    public Task<Report> BuildAsync() { ... }
}

Register it from DI:

services.AddInterceptors()
    .AddTimeout();

services.AddScopedWithInterception<IReportService, ReportService>();

The timeout is enforced on Task/Task<T> and ValueTask/ValueTask<T>-returning methods; a synchronous method cannot be interrupted once running, so the timeout is a no-op there.

If the method takes a CancellationToken, it is handed one that is cancelled when the time is up (as well as when the caller's is), and given CancellationGraceMilliseconds (default 250) to stop before the caller gets its TimeoutException. That wait is what keeps [RetryOnException] from starting an attempt while the one before it is still running. A method that completes in that time returns its result; one that fails has its exception as the InnerException.

A method that takes no token, or ignores it, keeps running in the background: [Timeout] then only bounds how long the caller waits, and retried attempts can overlap. Do not combine that with a [Transactional] method on a shared DbContext.

Circuit breaker

Decorate a method with [CircuitBreaker] and it stops being called once it has failed repeatedly: further calls fail immediately with a CircuitBreakerOpenException instead of piling more load onto a dependency that is already down.

using Innovabit.DotNet.Interceptors.Collections.CircuitBreakers;

public class CatalogClient : ICatalogClient
{
    [CircuitBreaker(FailureThreshold = 5, DurationOfBreakMs = 30_000, ExceptionType = typeof(HttpRequestException))]
    public Task<Product> GetAsync(string sku) { ... }
}

Register it from DI:

services.AddInterceptors()
    .AddCircuitBreaker();

services.AddScopedWithInterception<ICatalogClient, CatalogClient>();

Options ([CircuitBreaker])

  • FailureThreshold — consecutive failures that open the circuit (default 5). A single success resets the count.
  • DurationOfBreakMs — how long the circuit stays open before a trial call is allowed through (default 30000).
  • SuccessThreshold — consecutive successful trial calls that close the circuit again (default 1).
  • ExceptionType — only these exceptions count as a failure; others are re-thrown without touching the circuit. When unset, every exception counts.

A call the caller cancelled through the method's CancellationToken never counts, and neither does one that was already running when the circuit last changed state.

How it behaves

State What happens
Closed Calls go through; consecutive failures are counted.
Open Calls are rejected with CircuitBreakerOpenException (which carries RetryAfter) without reaching the method, until the break elapses.
HalfOpen Exactly one trial call at a time is let through. A success closes the circuit, a failure opens it again for another full break.

Circuits are tracked per method in a singleton CircuitBreakerRegistry — shared by every caller, because state that reset per request would never break anything. Inject the registry to inspect a circuit (GetState(MethodInfo)) from a health check, or reset them all with Reset(). Tests can drive time with AddCircuitBreaker(TimeProvider) instead of waiting out the break.

Put [CircuitBreaker] on the call that leaves your process, not on the orchestrating method above it. It runs at InterceptorOrders.CircuitBreaker (400), above retry (500), so an open circuit rejects the call before the retry loop spends its attempts on a dependency that is known to be down.

Fallback

Decorate a method with [Fallback(nameof(Other))] and a failure is answered by another method on the same class instead of reaching the caller: a cached figure instead of a live one, an empty list instead of an error, a second provider instead of the first.

using Innovabit.DotNet.Interceptors.Collections.Fallbacks;

public class QuoteClient : IQuoteClient
{
    [Fallback(nameof(GetCachedAsync), ExceptionType = typeof(HttpRequestException))]
    public Task<Quote> GetAsync(string symbol) => _api.FetchAsync(symbol);

    public Task<Quote> GetCachedAsync(string symbol) => Task.FromResult(_lastKnown[symbol]);
}

Register it from DI:

services.AddInterceptors()
    .AddFallback();

services.AddScopedWithInterception<IQuoteClient, QuoteClient>();

Options ([Fallback])

  • Method — name of the alternative, on the same class, taking the same parameters and returning a compatible type. Use nameof so a rename cannot break it.
  • ExceptionType — only fall back for these failures. When unset, every exception falls back.

Set ExceptionType to the one failure you actually have an answer for. Falling back on any exception is how a broken method turns into one that quietly returns the wrong thing.

How it behaves

The alternative is invoked directly on the target, not through the proxy, so it is not itself intercepted — that is what stops a failing fallback from falling back to itself forever, retrying itself, or counting against the same circuit. If the alternative throws, its exception is what the caller sees: there was nothing left to try.

Misconfiguration fails loudly rather than at the worst possible moment: a name that matches no method, a signature that does not line up, a return type that cannot stand in, or a fallback pointing at itself all throw on the first call with a message saying which.

It runs at InterceptorOrders.Fallback (350) — outside the circuit breaker (400), because an open circuit is exactly when a fallback earns its keep, and inside notifications (300), so a failure it handled does not page anyone.

Part of

The Innovabit.DotNet.Interceptors suite — github.com/Innovabit/dotnet-interceptors.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Innovabit.DotNet.Interceptors.Collections:

Package Downloads
Innovabit.DotNet.Interceptors.All

Meta-package: every interceptor concern in the suite (logging, validation, caching, notifications, telemetry, audit, authorization, rate limiting, coordination, feature gates, transactions, retry/timeout/circuit breaker/fallback) in one reference. Providers are separate packages — pick the ones you use.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.136 51 12/5/2026
3.0.135 205 11/30/2026
3.0.134 105 11/30/2026
3.0.133 102 11/30/2026
3.0.132 119 11/30/2026
3.0.129 94 11/30/2026
3.0.128 105 11/30/2026
3.0.127 125 11/30/2026
3.0.126 115 11/30/2026
3.0.125 107 11/30/2026
3.0.124 131 11/28/2026
3.0.123 110 11/28/2026
3.0.122 231 11/21/2026
2.0.121 118 11/21/2026
2.0.120 119 11/21/2026
2.0.119 170 11/14/2026
2.0.118 140 11/7/2026
2.0.117 151 10/31/2026
2.0.116 139 10/26/2026
2.0.115 143 10/17/2026
Loading failed