Skip to content

Dzmitryi Basau#281

Open
BasovDmitry wants to merge 3 commits intocrexi-dev:masterfrom
BasovDmitry:master
Open

Dzmitryi Basau#281
BasovDmitry wants to merge 3 commits intocrexi-dev:masterfrom
BasovDmitry:master

Conversation

@BasovDmitry
Copy link

Rate-limiting implementation.

Dzmitryi Basau added 3 commits January 31, 2025 16:31
Updated RateLimiter.Tests.csproj to include Moq for mocking in tests.
Significantly refactored RateLimiterTest.cs by replacing the single
RateLimiterTest class with multiple test classes: FixedWindowRuleTests,
SlidingWindowRuleTests, RegionalRuleTests, RateLimiterTests, and
ConcurrencyTests. Each class contains multiple test methods.

Updated RateLimiter.csproj to include Microsoft.Extensions.Logging for
logging capabilities.

Added RateLimiter.cs with the following:
- IRateLimitRule interface with IsAllowed and Cleanup methods.
- FixedWindowRule class implementing IRateLimitRule using a fixed window
  algorithm.
- SlidingWindowRule class implementing IRateLimitRule using a sliding
  window algorithm.
- RegionalRule class implementing IRateLimitRule applying rules based on
  client's region.
- RateLimiter class managing multiple rate limiting rules and logging
  blocked requests.
Refactored the `IRateLimitRule`, `FixedWindowRule`, `SlidingWindowRule`, and `RegionalRule` classes into their own files within the `RateLimiter.Rules` namespace to improve code organization and modularity. Updated `RateLimiterTest.cs` and `RateLimiter.cs` to reflect these changes. Added additional region checks for "ASIA" and a default "GLOBAL" region in the `RegionalRule` class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant