NeoAgi.Threading.RateLimiting 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NeoAgi.Threading.RateLimiting --version 0.1.0
                    
NuGet\Install-Package NeoAgi.Threading.RateLimiting -Version 0.1.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="NeoAgi.Threading.RateLimiting" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NeoAgi.Threading.RateLimiting" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="NeoAgi.Threading.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 NeoAgi.Threading.RateLimiting --version 0.1.0
                    
#r "nuget: NeoAgi.Threading.RateLimiting, 0.1.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 NeoAgi.Threading.RateLimiting@0.1.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=NeoAgi.Threading.RateLimiting&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=NeoAgi.Threading.RateLimiting&version=0.1.0
                    
Install as a Cake Tool

Overview

Simple Abstractions over the System.Threading.RateLimiting namespace with the goal of simplifying the API for callers.

This library does not intend to replace the System.Threading.RateLimiting Namespace. Simply make working with some aspects of it easier under some contexts.

Extension Methods

ConcurrentQueue<T>

Processing a ConcurrentQueue will continue until the cancellation token is cancelled or the queue is empty allowing for work to add more work which will be completed.

ProcessWithTPSAsync()

This abtraction calls TokenBucketRateLimiter with options designed to keep the calls to this function below a set Transactions Per Second by using assumptions.

This call does not attmpet to keep the throughput at the set TPS, but will ensure it will not go over that set amount. In testing TPS can only be reached with a high concurrency value.

Concurrency does not directly imply the number of threas as that depends on how the work is performed within the callback. General guidance is to set concurrency proprotational to the complexity of the call, lower values for callbacks that complete quickly, larger for callbacks that require more time.

Example Call:

var stringQueue = new ConcurrentQueue<string>();
// Fill the queue
await stringQueue.ProcessWithTPSAsync(maxTransactionsPerSecond, concurrentResourceCount, async (action) =>
{
    // Perform work once TPS falls below the threshold
});

Note: This extension limits processing of the queue to a single thread, fanning out processing to sub-threads.

ProcessWithRateLimitAsync()

This abstraction resides just above the TokenBucketRateLimiter exposing most of the core API with added clarity to the options.

If processing of the queue is intended to be handled by multiple threads or further tuning of the delegation to worker threads, this extension is more appropriate to use.

Example Call:

var stringQueue = new ConcurrentQueue<string>();
// Fill the queue
await stringQueue.ProcessWithRateLimitAsync(new ThroughputConcurrencyOptions()
{
    ConcurrencyLimit = 20,
    ReplinshmentPeriod = TimeSpan.FromSeconds(10),
    TasksPerPeriod = 50
}, async (value) =>
{
    // Do work
});
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

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
9.0.0 32,154 11/5/2025
0.1.0 36,872 10/15/2023