Skip to content
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

Add support for denominators to throttle strings #9089

Closed
wants to merge 7 commits into from

Conversation

awiebe
Copy link

@awiebe awiebe commented Aug 25, 2023

Description

Improved denominator string parser so you can for example write 1/30s for 1 request every 30 seconds instead of being limited to throttling by to the closest time unit. Since the current code just uses a lookup table on the denominator, it's pretty straightforward just to jiggle the indexing to look at the end of the string for the suffix, and see if there is a number in the denominator.

I imagine some documentation would also need to be updated. But I figured I would get the ball rolling since it seems a straightforward feature.

awiebe added 7 commits August 25, 2023 16:25
Improved denominator string parser so you can for example write `1/30s` for 1 request every 30 seconds instead of being limited to throttling by to the closest time unit.
Flake8 newline empty
@awiebe
Copy link
Author

awiebe commented Aug 26, 2023

Ok so it turned out to be a little more complicated than just fiddling with string indexes, since units can be spelled out. But a simple regex does the trick.

@sevdog
Copy link
Contributor

sevdog commented Sep 5, 2023

This resembles #9079

@tomchristie
Copy link
Member

Appreciate the input, tho... https://github.com/encode/django-rest-framework/blob/master/CONTRIBUTING.md

At this point in its lifespan we consider Django REST framework to be essentially feature-complete. We may accept pull requests that track the continued development of Django versions, but would prefer not to accept new features or code formatting changes.

@tomchristie tomchristie closed this Jan 4, 2024
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.

3 participants