HostLoom.RateLimiting 0.20.0

dotnet add package HostLoom.RateLimiting --version 0.20.0
                    
NuGet\Install-Package HostLoom.RateLimiting -Version 0.20.0
                    
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="HostLoom.RateLimiting" Version="0.20.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HostLoom.RateLimiting" Version="0.20.0" />
                    
Directory.Packages.props
<PackageReference Include="HostLoom.RateLimiting" />
                    
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 HostLoom.RateLimiting --version 0.20.0
                    
#r "nuget: HostLoom.RateLimiting, 0.20.0"
                    
#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 HostLoom.RateLimiting@0.20.0
                    
#: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=HostLoom.RateLimiting&version=0.20.0
                    
Install as a Cake Addin
#tool nuget:?package=HostLoom.RateLimiting&version=0.20.0
                    
Install as a Cake Tool

HostLoom.RateLimiting

Backend-neutral asynchronous token-bucket rate limiting over System.Threading.RateLimiting.RateLimiter. The package includes an in-process reference store; HostLoom.Redis and HostLoom.Valkey provide shared stores, and HostLoom.RateLimiting.HttpClient integrates outgoing HTTP clients.

var store = new InMemoryRateLimitStore();
var limiter = new DistributedRateLimiter(
    new RateLimitingOptions
    {
        Namespace = "catalog",
        TokenBucket = new TokenBucketRateLimitPolicy
        {
            TokenLimit = 100,
            TokensPerPeriod = 100,
            ReplenishmentPeriod = TimeSpan.FromSeconds(1),
        },
    },
    "catalog-api",
    store);

using var lease = await limiter.AcquireAsync(cancellationToken: stoppingToken);
if (!lease.IsAcquired)
{
    // Inspect MetadataName.RetryAfter before scheduling independent work.
}

AcquireAsync is the supported acquisition operation. AttemptAcquire returns a conservative failed lease without store I/O so hosts such as ASP.NET Core can fall back to asynchronous acquisition. Token-bucket leases do not refund permits on disposal.

The store receives fully prefixed {namespace}:rate:{key} keys. A rejected lease can contain MetadataName.RetryAfter and RateLimitMetadata.RemainingPermits. Store failure is different from quota exhaustion: OnUnavailable = Deny (the default) returns unavailable metadata, while explicit Allow admits work with degraded metadata. Caller cancellation propagates, and an ambiguous backend result is never replayed or refunded.

Every instance using the same namespace and key must use the same token-bucket policy. Redis and Valkey replication is asynchronous, so failover can lose recently consumed tokens; this is shared coordination, not an absolute quota guarantee during failover.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on HostLoom.RateLimiting:

Package Downloads
HostLoom.RateLimiting.DependencyInjection

Named dependency-injection registration, options validation, and readiness for HostLoom rate limiting.

HostLoom.RateLimiting.HttpClient

Outgoing HttpClient rate limiting with bounded local waits over HostLoom limiter profiles.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.0 126 10/31/2026