AdvancedRequestThrottler, .NET uygulamalarında istek hızını sınırlamak ve yönetmek için geliştirilmiş bir kütüphanelidir. Hız sınırlandırma algoritmaları ve kuyruklama sistemi ile API trafiğini kontrol etmeyi kolaylaştırır.
- Hız Sınırlandırma Algoritmaları
- Sabit Pencere (Fixed Window) algoritması
- Thread-safe hız sınırlandırma mekanizmaları
- Kuyruklama Sistemi
- İş yükü yönetimi için bellek içi kuyruklama
- Kolay Entegrasyon
IServiceCollectionveIHttpClientBuilderuzantıları ile hızlı kurulum- Esnek hız sınırlayıcı ve kuyruk konfigürasyonu
- Arka Plan Hizmeti
- Kuyruktaki işlemleri arka planda otomatik tüketme
NuGet paketleri üzerinden gelecektir. şu anda manuel ekleyerek kullanabilirsiniz.
services.AddRequestThrottling(options =>
{
options.Limit = 10; // Maksimum 10 istek
options.Window = TimeSpan.FromSeconds(60); // 60 saniyelik zaman penceresi
});services.AddHttpClient("ThrottledClient")
.AddThrottling(options =>
{
options.Limit = 5; // Maksimum 5 istek
options.Window = TimeSpan.FromSeconds(30); // 30 saniyelik zaman penceresi
});public class MyService
{
private readonly IInMemoryThrottleQueue _queue;
public MyService(IInMemoryThrottleQueue queue)
{
_queue = queue;
}
public async Task AddToQueueAsync(Func<Task> action)
{
await _queue.EnqueueAsync(action);
}
}-
RateLimiter
İsteklerin hız sınırlandırmasını kontrol eder.
Örnek:FixedWindowRateLimiter -
ThrottleQueue
İstekleri kuyruklar ve sıralı şekilde işler.
Örnek:InMemoryThrottleQueue -
Extensions
Hız sınırlayıcı ve kuyruk mekanizmalarını kolayca entegre etmek için uzantılar sunar. -
HostedService
Kuyruktaki işlemleri arka planda tüketen servis:QueueConsumerHostedService
Katkıda bulunmak için:
- Bu repo'yu fork edin.
- Yeni bir branch oluşturun:
git checkout -b my-feature-branch
- Değişikliklerinizi yapın ve commit edin:
git commit -m 'Yeni bir özellik ekle' - Branch'inizi pushlayın:
git push origin my-feature-branch
- Pull Request oluşturun.
Bu proje MIT Lisansı ile lisanslanmıştır.
AdvancedRequestThrottler is a .NET library designed to manage and limit request rates within applications. It simplifies API traffic control with rate-limiting mechanisms and a queueing system.
- Rate Limiting Algorithms
- Fixed Window algorithm
- Thread-safe rate-limiting mechanisms
- Queueing System
- In-memory queue management
- Easy Integration
- Simple setup with
IServiceCollectionandIHttpClientBuilder
- Simple setup with
- Background Service
- Automatic queue consumption with a hosted service
Coming soon on NuGet.
Currently, you can clone and reference manually.
services.AddRequestThrottling(options =>
{
options.Limit = 10; // Maximum 10 requests
options.Window = TimeSpan.FromSeconds(60); // 60-second time window
});services.AddHttpClient("ThrottledClient")
.AddThrottling(options =>
{
options.Limit = 5; // Maximum 5 requests
options.Window = TimeSpan.FromSeconds(30); // 30-second time window
});public class MyService
{
private readonly IInMemoryThrottleQueue _queue;
public MyService(IInMemoryThrottleQueue queue)
{
_queue = queue;
}
public async Task AddToQueueAsync(Func<Task> action)
{
await _queue.EnqueueAsync(action);
}
}-
RateLimiter
Controls the rate limiting of requests.
Example:FixedWindowRateLimiter -
ThrottleQueue
Queues requests and processes them sequentially.
Example:InMemoryThrottleQueue -
Extensions
Provides extension methods for easy integration. -
HostedService
Consumes tasks in the queue usingQueueConsumerHostedService.
- Fork this repository.
- Create a new branch:
git checkout -b my-feature-branch
- Make your changes and commit:
git commit -m 'Add some feature' - Push your branch:
git push origin my-feature-branch
- Open a Pull Request.
This project is licensed under the MIT License.