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

Feature Requests/ideas: shorter 'until' time intervals, Leaky bucket algorithm, Atomic cache operations #12

Open
maximehinnekens opened this issue Sep 24, 2024 · 0 comments

Comments

@maximehinnekens
Copy link

Until time intervals

As of now two methods exists that already implement this:
untilMidnightTonight, untilEndOfMonth

However it would be great to have these available as well for shorter time intervals such as:
untilEndOfMinute, untilEndOfHour

Some of the external api's I work with rely on clock minutes. So if you have a rate limit of 100 per second and you call them all at 12:50:50, it will reset at 12:51:00 and not at 12:51:50. This has been a common issue for me when setting up rate limiting. I used to make a Redis key with a stringified version of the current time (with minute/hour notation depending on what the limit reset was). Now that I discovered this amazing package (thanks by the way, I'm becoming a huge fan), it affects me once again by having to substract the seconds till the next minute etc, makes the code hard to read.

Leaky bucket algorithm

This one is also a very popular rate limiting algorithm (used by Amazon Marketplace api for example). This would be so great if it were also supported out of the box.

Atomic cache operations

I'm not sure how many people are affected by this. However, when an app is doing calls at extremely high concurrency, it would be very beneficial to prevent accidental 429's by implementing Atomic operations to set and get the hits on cache stores such as Redis. There are GETSET,LUA evals etc which are very suitable for this. I believe that this can make the threshold obsolete as it becomes impossible to hit the configured limits, even at high concurrency.

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

No branches or pull requests

1 participant