-
Couldn't load subscription status.
- Fork 252
CLDSRV-767: Add counter and cached config storage #5977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLDSRV-767: Add counter and cached config storage #5977
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces in-memory storage mechanisms for rate limiting functionality, including GCRA counters and cached bucket limit configurations. The implementation uses JavaScript Maps to provide simple, ephemeral storage for rate limit tracking.
Key Changes:
- Added cache module with counter storage and cached config storage functionality
- Implemented expiration mechanisms for both counters and cached configurations
- Created comprehensive unit tests covering storage, retrieval, and expiration behaviors
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/api/apiUtils/rateLimit/cache.js | Implements in-memory storage for GCRA counters and limit configurations with expiration logic |
| tests/unit/api/apiUtils/rateLimit/cache.js | Provides unit test coverage for counter and config cache operations including expiration scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files
@@ Coverage Diff @@
## improvement/CLDSRV-766/bucket_rate_limiting #5977 +/- ##
===============================================================================
+ Coverage 82.57% 82.60% +0.03%
===============================================================================
Files 194 195 +1
Lines 12324 12352 +28
===============================================================================
+ Hits 10176 10203 +27
- Misses 2148 2149 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
|
||
| function expireCachedConfigs(now) { | ||
| const toRemove = []; | ||
| for (const [key, { expiry }] of configCache.entries()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I didn't know you could nest the exploding-style assignment
84fa622 to
eb4a19a
Compare
fcc2688
into
improvement/CLDSRV-766/bucket_rate_limiting
Adds simple in memory storage for GCRA counters and cached bucket limit configurations.
Note for reviewers: This is being merged into a feature branch that has existing skeleton code. All unreviewed code will be gone over/reworked before merging into development/9.0