impr(CLDSRV-852): Refactor WorkerTokenBucket#6108
Conversation
❌ 109 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
446cb3b to
ee952c3
Compare
|
LGTM |
4b83cef to
b40ff80
Compare
ee952c3 to
a68c32e
Compare
b40ff80 to
100976b
Compare
5a26928 to
e34db4d
Compare
|
Clean refactoring. The removal of |
Review by Claude Code |
…urceClass, resourceId, and measure
7be0a34 to
4cc343b
Compare
|
| const tokenBuckets = new Map(); | ||
|
|
||
| /** | ||
| * Per-bucket token bucket for a single worker |
There was a problem hiding this comment.
The class JSDoc still says "Per-bucket token bucket for a single worker". The class now handles any resource class (bucket, account, etc.) and the worker framing was removed from the architecture (rate limiting is now per-node). Does the comment still match the class's role?
- Change constructor to accept resourceClass, resourceId, measure - Precalculate interval for reuse in constructor - Add hasCapacity() method - Add updateLimit() method to encasulate limit change logic - Remove unused mechanism to record request durations - Simplify refill logic
4cc343b to
63bdf28
Compare
cd2c42f
into
improvement/CLDSRV-869/account_limiting
| this.bufferSize = config.rateLimiting?.tokenBucketBufferSize || 50; // Max tokens to hold | ||
| this.refillThreshold = config.rateLimiting?.tokenBucketRefillThreshold || 20; // Trigger refill when below this | ||
| this.bufferSize = config.rateLimiting?.tokenBucketBufferSize; // Max tokens to hold | ||
| this.refillThreshold = config.rateLimiting?.tokenBucketRefillThreshold; // Trigger refill when below this |
There was a problem hiding this comment.
The constructor reads bufferSize and refillThreshold with optional chaining (config.rateLimiting?.tokenBucketBufferSize), but then accesses config.rateLimiting.nodes on line 36 without optional chaining. If config.rateLimiting is undefined, this will throw a TypeError. Since rate limiting must be configured to reach this code path, drop the unnecessary optional chaining for consistency.
— Claude Code
Review by Claude Code |
Note for revewers: S3 API unit tests are still expected to fail