Skip to content

feat: make key prefix configurable #111

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

Open
wants to merge 1 commit into
base: v10
Choose a base branch
from

Conversation

jaimem88
Copy link

@jaimem88 jaimem88 commented Feb 28, 2025

This PR will allow the Limiter to be optionally configured with a key prefix. This makes the limiter more flexible as not all applications need to be prefixed with rate:.

Using the Options pattern ensures we do not break backwards compatibility and will still use the default value.

Users of this package can chose to:

  • Not use WithKeyPrefix when initializing the limiter to use the default value of rate:
  • Set WithKeyPrefix("") to remove all prefixes from the used keys.
  • Set whatever prefix they want.

I extended the TestAllow to use different key prefixes. I don't think it's necessary to extend the other tests as this already shows things work as expected.


For extra context, we are looking at using this package for https://gitlab.com/gitlab-org/container-registry, however this is a current limitation we have given our guidelines.

@jaimem88
Copy link
Author

@vmihailenco would you consider this change?

@jaimem88
Copy link
Author

cc @joaodrp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant