-
Notifications
You must be signed in to change notification settings - Fork 35
Support AttachedTo metadata for policies #684
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
base: main
Are you sure you want to change the base?
Conversation
…Limit (#1) * Implement AttachedTo metadata for policy differentiation - Updated SDK PolicyMetadata to include AttachedTo field - Updated Gateway Controller to inject AttachedTo parameter ("api" or "route") during policy conversion - Updated Policy Engine to extract AttachedTo from parameters and set it in PolicyMetadata - Updated Basic Rate Limit policy to use "apiname" key extractor when AttachedTo is "api" * Implement AttachedTo metadata for policy differentiation - Updated SDK PolicyMetadata to include AttachedTo field - Updated Gateway Controller to inject AttachedTo parameter ("api" or "route") during policy conversion - Updated Policy Engine to extract AttachedTo from parameters and set it in PolicyMetadata - Updated Basic Rate Limit policy to use "apiname" key extractor when AttachedTo is "api" - Updated integration tests to verify new behavior and fix regressions caused by scoping changes * Resolve conflicts and fix tests for rate limit scoping - Merged latest changes from ratelimit-latest. - Updated `gateway/it/features/basic-ratelimit.feature` to align with the new rate limiting behavior: - API-level attachment now implies a shared bucket (per API). - Route-level attachment (per operation) implies independent buckets. - Adjusted test expectations and configurations accordingly. - Verified that all integration tests pass. * Resolve conflicts and update rate limit tests - Merged latest changes from ratelimit-latest. - Updated `gateway/it/features/basic-ratelimit.feature` to align with the new rate limiting behavior: - API-level attachment now implies a shared bucket (per API). - Route-level attachment (per operation) implies independent buckets. - Adjusted test expectations and configurations accordingly. - Verified that all integration tests pass. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Tharsanan1 <ktharsanan@gmail.com>
WalkthroughThe changes introduce an Changes
Sequence DiagramsequenceDiagram
participant Controller as Gateway Controller
participant Engine as Policy Engine
participant PolicyImpl as Rate Limit Policy
Controller->>Controller: convertAPIPolicy(policy, attachedTo)
Note over Controller: Insert attachedTo into Parameters
Controller->>Engine: Policy with attachedTo in Parameters
Engine->>Engine: buildPolicyChain(policyConfig)
Engine->>Engine: Read attachedTo from Parameters
Engine->>Engine: Populate metadata.AttachedTo
Note over Engine: metadata = {AttachedTo: "api"|"route"}
Engine->>PolicyImpl: CreateInstance(metadata)
PolicyImpl->>PolicyImpl: transformToRatelimitParams(params, metadata)
alt metadata.AttachedTo == "api"
PolicyImpl->>PolicyImpl: keyExtraction = "apiname"
else
PolicyImpl->>PolicyImpl: keyExtraction = "routename"
end
Note over PolicyImpl: Enforce limits per scope
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2026-01-13T15:42:24.281ZApplied to files:
🧬 Code graph analysis (3)gateway/policies/basic-ratelimit/v0.1.0/basic_ratelimit.go (1)
gateway/gateway-controller/cmd/controller/main.go (2)
gateway/gateway-controller/pkg/api/handlers/handlers.go (2)
🔇 Additional comments (12)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
$subject
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.