From 278453d5df19cc24fad28a3cd0ea58ee60a03348 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 2 Sep 2025 09:53:08 +0100 Subject: [PATCH 1/6] clean up system clock --- src/Throttlr.Api.RateLimit/Abstractions/ISystemClock.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Throttlr.Api.RateLimit/Abstractions/ISystemClock.cs b/src/Throttlr.Api.RateLimit/Abstractions/ISystemClock.cs index 22efb19..33f74b8 100644 --- a/src/Throttlr.Api.RateLimit/Abstractions/ISystemClock.cs +++ b/src/Throttlr.Api.RateLimit/Abstractions/ISystemClock.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; -using System.Text; namespace RateLimit.Throttlr.Abstractions { /// /// Provides an abstraction for accessing the current UTC system clock. - /// Useful for unit testing and time-based rate limiting algorithms. /// public interface ISystemClock { From d106622dbc6c417a2cf31f9d5b1b8b06261b8943 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 2 Sep 2025 09:53:24 +0100 Subject: [PATCH 2/6] clean up Sliding Window --- src/Throttlr.Api.RateLimit/Core/Counter/SlidingWindowCounter.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Throttlr.Api.RateLimit/Core/Counter/SlidingWindowCounter.cs b/src/Throttlr.Api.RateLimit/Core/Counter/SlidingWindowCounter.cs index a8dd4e8..7283ca3 100644 --- a/src/Throttlr.Api.RateLimit/Core/Counter/SlidingWindowCounter.cs +++ b/src/Throttlr.Api.RateLimit/Core/Counter/SlidingWindowCounter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace RateLimit.Throttlr.Core.Counter { From f36d0750138cca580d479b567d6e90fc639e2cdd Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 2 Sep 2025 09:53:45 +0100 Subject: [PATCH 3/6] clean up InMemoryRateLimitStore --- .../Core/Store/InMemoryRateLimitStore.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Throttlr.Api.RateLimit/Core/Store/InMemoryRateLimitStore.cs b/src/Throttlr.Api.RateLimit/Core/Store/InMemoryRateLimitStore.cs index b84b9eb..fd6f536 100644 --- a/src/Throttlr.Api.RateLimit/Core/Store/InMemoryRateLimitStore.cs +++ b/src/Throttlr.Api.RateLimit/Core/Store/InMemoryRateLimitStore.cs @@ -13,10 +13,7 @@ namespace RateLimit.Throttlr.Core.Store internal class InMemoryRateLimitStore : IRateLimitStore { private readonly ConcurrentDictionary _counters; - - /// - /// Initializes a new instance of the class. - /// + public InMemoryRateLimitStore() { _counters = new ConcurrentDictionary( From 31242aff332f52ce94a8293f3f9949d23d98b3dd Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 2 Sep 2025 09:54:17 +0100 Subject: [PATCH 4/6] remove comment from constructor --- src/Throttlr.Api.RateLimit/Core/TokenBucketRateLimiter.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Throttlr.Api.RateLimit/Core/TokenBucketRateLimiter.cs b/src/Throttlr.Api.RateLimit/Core/TokenBucketRateLimiter.cs index 5cc95c0..262827b 100644 --- a/src/Throttlr.Api.RateLimit/Core/TokenBucketRateLimiter.cs +++ b/src/Throttlr.Api.RateLimit/Core/TokenBucketRateLimiter.cs @@ -20,12 +20,6 @@ public sealed class TokenBucketRateLimiter : IRateLimiter private readonly int _capacity; private readonly double _tokensPerSecond; - /// - /// Initializes a new instance of the class. - /// - /// The rate limit store. - /// The rate limit policy. - /// The system clock. public TokenBucketRateLimiter( IRateLimitStore store, ISystemClock clock, From d633d42bc88b3af122beb937c57c00abaf6be1e1 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 2 Sep 2025 09:54:25 +0100 Subject: [PATCH 5/6] remove comment from constructor --- src/Throttlr.Api.RateLimit/Core/FixedWindowRateLimiter.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Throttlr.Api.RateLimit/Core/FixedWindowRateLimiter.cs b/src/Throttlr.Api.RateLimit/Core/FixedWindowRateLimiter.cs index b33a37f..b02a451 100644 --- a/src/Throttlr.Api.RateLimit/Core/FixedWindowRateLimiter.cs +++ b/src/Throttlr.Api.RateLimit/Core/FixedWindowRateLimiter.cs @@ -18,12 +18,6 @@ internal class FixedWindowRateLimiter : IRateLimiter private readonly ISystemClock _clock; private readonly RateLimitPolicy _policy; - /// - /// Initializes a new instance of the class. - /// - /// Backing store for counters. - /// Clock abstraction for testability. - /// Rate limit policy definition. public FixedWindowRateLimiter( IRateLimitStore store, ISystemClock clock, From 11210c20874b6acd978feffe1f4b99758b300a10 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 2 Sep 2025 09:54:38 +0100 Subject: [PATCH 6/6] update core services --- src/Throttlr.Api.RateLimit/Core/RateLimitResult.cs | 8 ++++---- .../Core/SlidingWindowRateLimiter.cs | 4 ---- src/Throttlr.Api.RateLimit/Core/SystemClock.cs | 3 --- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Throttlr.Api.RateLimit/Core/RateLimitResult.cs b/src/Throttlr.Api.RateLimit/Core/RateLimitResult.cs index 9b65a70..5c67483 100644 --- a/src/Throttlr.Api.RateLimit/Core/RateLimitResult.cs +++ b/src/Throttlr.Api.RateLimit/Core/RateLimitResult.cs @@ -2,11 +2,11 @@ namespace RateLimit.Throttlr.Core { + /// + /// Represents the result of a rate limit check. + /// public sealed class RateLimitResult - { - /// - /// Represents the result of a rate limit check. - /// + { private RateLimitResult(bool isAllowed, int? retryAfterSeconds = null) { IsAllowed = isAllowed; diff --git a/src/Throttlr.Api.RateLimit/Core/SlidingWindowRateLimiter.cs b/src/Throttlr.Api.RateLimit/Core/SlidingWindowRateLimiter.cs index 0f0e7aa..04c85ab 100644 --- a/src/Throttlr.Api.RateLimit/Core/SlidingWindowRateLimiter.cs +++ b/src/Throttlr.Api.RateLimit/Core/SlidingWindowRateLimiter.cs @@ -18,9 +18,6 @@ internal class SlidingWindowRateLimiter : IRateLimiter private readonly ISystemClock _clock; private readonly RateLimitPolicy _policy; - /// - /// Initializes a new instance of the class. - /// public SlidingWindowRateLimiter( IRateLimitStore store, ISystemClock clock, @@ -31,7 +28,6 @@ public SlidingWindowRateLimiter( _policy = policy ?? throw new ArgumentNullException(nameof(policy)); } - /// /// public async Task ShouldLimitAsync( string key, diff --git a/src/Throttlr.Api.RateLimit/Core/SystemClock.cs b/src/Throttlr.Api.RateLimit/Core/SystemClock.cs index c436c75..7d9c3c9 100644 --- a/src/Throttlr.Api.RateLimit/Core/SystemClock.cs +++ b/src/Throttlr.Api.RateLimit/Core/SystemClock.cs @@ -5,9 +5,6 @@ namespace RateLimit.Throttlr.Core { - /// - /// Default implementation of that uses . - /// public sealed class SystemClock : ISystemClock { ///