HostLoom.RateLimiting
0.20.0
dotnet add package HostLoom.RateLimiting --version 0.20.0
NuGet\Install-Package HostLoom.RateLimiting -Version 0.20.0
<PackageReference Include="HostLoom.RateLimiting" Version="0.20.0" />
<PackageVersion Include="HostLoom.RateLimiting" Version="0.20.0" />
<PackageReference Include="HostLoom.RateLimiting" />
paket add HostLoom.RateLimiting --version 0.20.0
#r "nuget: HostLoom.RateLimiting, 0.20.0"
#:package HostLoom.RateLimiting@0.20.0
#addin nuget:?package=HostLoom.RateLimiting&version=0.20.0
#tool nuget:?package=HostLoom.RateLimiting&version=0.20.0
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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- System.Threading.RateLimiting (>= 10.0.14)
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 |