oqo0.GenericRateLimiter 0.2.0

dotnet add package oqo0.GenericRateLimiter --version 0.2.0                
NuGet\Install-Package oqo0.GenericRateLimiter -Version 0.2.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="oqo0.GenericRateLimiter" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add oqo0.GenericRateLimiter --version 0.2.0                
#r "nuget: oqo0.GenericRateLimiter, 0.2.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.
// Install oqo0.GenericRateLimiter as a Cake Addin
#addin nuget:?package=oqo0.GenericRateLimiter&version=0.2.0

// Install oqo0.GenericRateLimiter as a Cake Tool
#tool nuget:?package=oqo0.GenericRateLimiter&version=0.2.0                

Generic rate limiter

Simple universal rate limiter. Don't use this for ASP.NET, use built in rate limiter instead.

Usage

builder.Services.AddRateLimiter<string>(x =>
{
    x.AddRateLimiter(1, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
    x.AddRateLimiter(5, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20));
});

Allows 1 request per 1 second and 5 requests in 10 seconds with ban time for 2 and 20 seconds.

public class SampleService(IEntityRateLimiter<int> entityRateLimiter) : IHostedService
{
    public async Task Method(CancellationToken cancellationToken)
    {
        // use any unique request identifier
        var rateLimitStatus = entityRateLimiter.Trigger("some request id");
    }
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.0 30 7/17/2024
0.0.2 78 7/5/2024