-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
feat: Add support for flexible throttling intervals #9079
feat: Add support for flexible throttling intervals #9079
Conversation
This commit introduces the ability to set custom time intervals for throttling, allowing users to specify intervals like per 5 minutes, per 2 hours, and per 5 days. This enhancement provides more flexibility in controlling request rates.
This commit introduces the ability to set custom time intervals for throttling, allowing users to specify intervals like per 5 minutes, per 2 hours, and per 5 days. This enhancement provides more flexibility in controlling request rates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an interesting feature. However the code must be cleaned and also docs and example must be written for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for having this ouside the throttling
package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought creating file inside the utils folder will more organised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that this method does not have any other use case, so IMO having an extra file for this does not seem good choice.
It could make sense if there was the need to have an utility method which needs to be used by throttling package and by others, as of new there is no need to have this in an extra package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense👍
quantity_unit_dict = {} | ||
while i < len(quantity_unit_string) and quantity_unit_string[i].isnumeric(): | ||
i += 1 | ||
if i == 0: | ||
quantity_unit_dict['quantity'] = 1 | ||
quantity_unit_dict['unit'] = quantity_unit_string | ||
else: | ||
quantity_unit_dict['quantity'] = int(quantity_unit_string[:i]) | ||
quantity_unit_dict['unit'] = quantity_unit_string[i:] | ||
return quantity_unit_dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a dict is a bit overcomplicated, why just not returning a simple tuple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your feedback !
I have updated it.
Co-authored-by: Devid <[email protected]>
I would really appreciate if you could help me and guide me further. |
…b.com/PravinKamble123/django-rest-framework into feature/flexible-throttling-intervals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still requires to be documented in throttling.md.
Before merging it would be good to squash (rebase) this branch into a single commit to keep the history as clean as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that this method does not have any other use case, so IMO having an extra file for this does not seem good choice.
It could make sense if there was the need to have an utility method which needs to be used by throttling package and by others, as of new there is no need to have this in an extra package.
Args: | ||
quantity_unit_string (str): A string that combines a numeric quantity and a unit, e.g., "5min", "10h". | ||
|
||
Returns: | ||
dict: A dictionary containing the parsed quantity and unit, with keys 'quantity' and 'unit'. | ||
If the input string contains only a unit (e.g., "m"), quantity will be set to 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not match any other docstring style in the project, it will just make confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not understand your point. Is it too much text ? or too long lines ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To put it simple: the part with Args:
and Returns:
are not used by any other comment in this repository. Keeping that here may cause confusion.
@sevdog @robhudson @roncohen need suggestion |
@PravinKamble123 wait for others to review this PR (please do not change what is done by maintainers of this repo). I already have done some checks on this PR, now you need to wait for furhter review and approval. |
@sevdog ok. |
This commit introduces the ability to set custom time intervals for throttling, allowing users to specify intervals like per 5 minutes, per 2 hours, and per 5 days. This enhancement provides more flexibility in controlling request rates.
…b.com/PravinKamble123/django-rest-framework into feature/flexible-throttling-intervals
@sevdog hi, |
@auvipy need feedback |
@PravinKamble123 You need to force push the squashed commit, as of now it is not available on github. |
@sevdog noted. |
Appreciate the input, tho... https://github.com/encode/django-rest-framework/blob/master/CONTRIBUTING.md
|
No worries. I think was very closed. Eveything was tested. Its was not
affecting the other functionality. Instead it was improving the
functionality. And it is reviewed and appreciated by one the contributor.
No problem.
Thanks
…On Thu, 4 Jan, 2024, 6:09 pm Tom Christie, ***@***.***> wrote:
Closed #9079 <#9079>.
—
Reply to this email directly, view it on GitHub
<#9079 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVXHOJFN7PU7M4ORQN7CPC3YM2PIFAVCNFSM6AAAAAA3XNQRW2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGM4DSNBSG4ZTQNY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Valid points, yep. |
If I want contribute again what should I have to do then
…On Thu, 4 Jan, 2024, 6:39 pm Tom Christie, ***@***.***> wrote:
Valid points, yep.
Perhaps if REST framework moves under alternative maintainer-ship the
CONTRIBUTING.md policy might change.
(Or perhaps not?)
—
Reply to this email directly, view it on GitHub
<#9079 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVXHOJA7DMR7MQA6NVQMUW3YM2SZBAVCNFSM6AAAAAA3XNQRW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXGA3TAOJZGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I want contribute to drf again with same enhancement.
This enhancement will make our current app more robust.
…On Wed, 4 Sept, 2024, 10:59 am pravin kamble, ***@***.***> wrote:
If I want contribute again what should I have to do then
On Thu, 4 Jan, 2024, 6:39 pm Tom Christie, ***@***.***>
wrote:
> Valid points, yep.
> Perhaps if REST framework moves under alternative maintainer-ship the
> CONTRIBUTING.md policy might change.
> (Or perhaps not?)
>
> —
> Reply to this email directly, view it on GitHub
> <#9079 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVXHOJA7DMR7MQA6NVQMUW3YM2SZBAVCNFSM6AAAAAA3XNQRW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXGA3TAOJZGY>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
may be creating an extension would be better for a while for new features or contribute to drf-extensions |
Thanks for feedback.
I have written only function. And I have tested it. I won't impact the
existing features.
This is just small enhancement I would say.
What if I create new fresh branch from master and do same changes?.
I respect all of your decisions but If you allow this would be my first
contribution to drf.
…On Wed, 4 Sept, 2024, 2:21 pm Asif Saif Uddin, ***@***.***> wrote:
may be creating an extension would be better for a while for new features
or contribute to drf-extensions
—
Reply to this email directly, view it on GitHub
<#9079 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVXHOJBLSZX2MGDRDSRUMDTZU3CZTAVCNFSM6AAAAABNTQHVLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRYGI4DIMZWGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
This commit introduces the ability to set custom time intervals for throttling, allowing users to specify intervals like per 5 minutes, per 2 hours, and per 5 days. This enhancement provides more flexibility in controlling request rates.
Note: Before submitting this pull request, please review our contributing guidelines.
Description
Please describe your pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. When linking to an issue, please use
refs #...
in the description of the pull request.