Repository navigation
Fix distributed token bucket refill across gateways - #51
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5f7878237
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| this(policyProvider, quotaCoordinator, capacityAllocator, | ||
| null, null, null); |
There was a problem hiding this comment.
Preserve token-bucket behavior for legacy constructors
Any caller using one of the pre-existing public constructors now gets a null bucket. When such an engine evaluates a TOKEN_BUCKET policy, evaluateDecision throws IllegalStateException instead of performing the previously supported quota evaluation. This affects existing consumers that instantiate the engine through the unchanged 3-, 4-, or 5-argument constructors; either supply a compatible bucket/fallback or make the new dependency mandatory rather than retaining broken overloads.
Useful? React with 👍 / 👎.
| Boolean tokenBucketDeleted = redisTemplate.delete( | ||
| buildTokenBucketRedisKey(capacityKey)); |
There was a problem hiding this comment.
Prevent removed buckets from being recreated
After removeCapacity deletes this hash, the next tryConsume recreates it with a full bucket because the Lua script initializes any missing state. Thus removing capacity does not actually prevent an active token-bucket policy from serving traffic: a request after removal restores and consumes the configured capacity. Preserve a removal marker or require registered capacity before lazy initialization so removal remains effective.
Useful? React with 👍 / 👎.



Overview
Implements a Redis-backed distributed token bucket to share rate-limit capacity and refill state atomically across gateway instances.
Changes
TrafficDecisionEngine.Testing
mvn test— 120 tests passed, 0 failures, 0 errors.git diff --cached --check— passed.