File tree Expand file tree Collapse file tree 8 files changed +5
-32
lines changed
src/Throttlr.Api.RateLimit Expand file tree Collapse file tree 8 files changed +5
-32
lines changed Original file line number Diff line number Diff line change 11using System ;
2- using System . Collections . Generic ;
3- using System . Text ;
42
53namespace RateLimit . Throttlr . Abstractions
64{
75 /// <summary>
86 /// Provides an abstraction for accessing the current UTC system clock.
9- /// Useful for unit testing and time-based rate limiting algorithms.
107 /// </summary>
118 public interface ISystemClock
129 {
Original file line number Diff line number Diff line change 11using System ;
2- using System . Collections . Generic ;
3- using System . Text ;
42
53namespace RateLimit . Throttlr . Core . Counter
64{
Original file line number Diff line number Diff line change @@ -18,12 +18,6 @@ internal class FixedWindowRateLimiter : IRateLimiter
1818 private readonly ISystemClock _clock ;
1919 private readonly RateLimitPolicy _policy ;
2020
21- /// <summary>
22- /// Initializes a new instance of the <see cref="FixedWindowRateLimiter"/> class.
23- /// </summary>
24- /// <param name="store">Backing store for counters.</param>
25- /// <param name="clock">Clock abstraction for testability.</param>
26- /// <param name="policy">Rate limit policy definition.</param>
2721 public FixedWindowRateLimiter (
2822 IRateLimitStore store ,
2923 ISystemClock clock ,
Original file line number Diff line number Diff line change 22
33namespace RateLimit . Throttlr . Core
44{
5+ /// <summary>
6+ /// Represents the result of a rate limit check.
7+ /// </summary>
58 public sealed class RateLimitResult
6- {
7- /// <summary>
8- /// Represents the result of a rate limit check.
9- /// </summary>
9+ {
1010 private RateLimitResult ( bool isAllowed , int ? retryAfterSeconds = null )
1111 {
1212 IsAllowed = isAllowed ;
Original file line number Diff line number Diff line change @@ -18,9 +18,6 @@ internal class SlidingWindowRateLimiter : IRateLimiter
1818 private readonly ISystemClock _clock ;
1919 private readonly RateLimitPolicy _policy ;
2020
21- /// <summary>
22- /// Initializes a new instance of the <see cref="SlidingWindowRateLimiter"/> class.
23- /// </summary>
2421 public SlidingWindowRateLimiter (
2522 IRateLimitStore store ,
2623 ISystemClock clock ,
@@ -31,7 +28,6 @@ public SlidingWindowRateLimiter(
3128 _policy = policy ?? throw new ArgumentNullException ( nameof ( policy ) ) ;
3229 }
3330
34- /// <inheritdoc />
3531 /// <inheritdoc />
3632 public async Task < RateLimitResult > ShouldLimitAsync (
3733 string key ,
Original file line number Diff line number Diff line change @@ -13,10 +13,7 @@ namespace RateLimit.Throttlr.Core.Store
1313 internal class InMemoryRateLimitStore : IRateLimitStore
1414 {
1515 private readonly ConcurrentDictionary < string , RateLimitCounter > _counters ;
16-
17- /// <summary>
18- /// Initializes a new instance of the <see cref="InMemoryRateLimitStore"/> class.
19- /// </summary>
16+
2017 public InMemoryRateLimitStore ( )
2118 {
2219 _counters = new ConcurrentDictionary < string , RateLimitCounter > (
Original file line number Diff line number Diff line change 55
66namespace RateLimit . Throttlr . Core
77{
8- /// <summary>
9- /// Default implementation of <see cref="ISystemClock"/> that uses <see cref="DateTimeOffset.UtcNow"/>.
10- /// </summary>
118 public sealed class SystemClock : ISystemClock
129 {
1310 /// <inheritdoc />
Original file line number Diff line number Diff line change @@ -20,12 +20,6 @@ public sealed class TokenBucketRateLimiter : IRateLimiter
2020 private readonly int _capacity ;
2121 private readonly double _tokensPerSecond ;
2222
23- /// <summary>
24- /// Initializes a new instance of the <see cref="TokenBucketRateLimiter"/> class.
25- /// </summary>
26- /// <param name="store">The rate limit store.</param>
27- /// <param name="policy">The rate limit policy.</param>
28- /// <param name="clock">The system clock.</param>
2923 public TokenBucketRateLimiter (
3024 IRateLimitStore store ,
3125 ISystemClock clock ,
You can’t perform that action at this time.
0 commit comments