Draft
Add CustomBaseRateLimiter extension for descriptor filtering, key derivation, and duplicate handling#1
Conversation
…rivation and duplicate handling Co-authored-by: shahparam <6872539+shahparam@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add CustomBaseRateLimiter extension for advanced rate limit customization
Add CustomBaseRateLimiter extension for descriptor filtering, key derivation, and duplicate handling
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BaseRateLimiterhas no extension points for customizing cache key generation, skipping rate limit checks for specific descriptors, or deduplicating descriptors before processing. This PR addsCustomBaseRateLimiteras a pure additive wrapper with three optional hooks.Core (
src/limiter/)custom_base_limiter.go— Embeds*BaseRateLimiter, overridesGenerateCacheKeysto apply filter and derivation hooks, addsHandleDuplicates. Fluent builder API viaWith*methods.descriptor_filters.go—AllowAll,DenyAll,FilterByKey,FilterByValue,FilterByKeyValuekey_derivations.go—IdentityKeyDerivation,PrefixKeyDerivation,SuffixKeyDerivation,HashSensitiveValueKeyDerivation,NormalizeKeyDerivationduplicate_handlers.go—PassThroughDuplicateHandler,KeepFirstDuplicateHandler,KeepLastDuplicateHandlerTests (
test/limiter/)custom_base_limiter_test.go— 26 unit tests covering hook behaviour, pre-built helpers, and edge cases (e.g. derivation not called when key is already empty)examples_test.go— 4 integration-style tests: internal-traffic bypass, multi-tenant key namespacing, deduplication, sensitive-token hashingUsage
DescriptorFilterFnreturningtruesets the cache key to"", causing an immediateOKwithout a cache lookup.KeyDerivationFnis skipped when the key is already empty.CustomBaseRateLimiterwith no hooks set is behaviourally identical toBaseRateLimiter.See
CUSTOMIZATION_README.mdfor the full integration guide.Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.