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 reset method to RateLimiter class #32

Merged
merged 3 commits into from
Nov 30, 2023
Merged

add reset method to RateLimiter class #32

merged 3 commits into from
Nov 30, 2023

Conversation

1yd1a
Copy link
Contributor

@1yd1a 1yd1a commented Nov 30, 2023

RateLimiter is a class we've occasionally used when we need to make the code wait for a specified period of time without interrupting the rest of the code. I think it would be helpful if the class had a method that simply resets the RateLimiter's "timer".

For example, let's say someone wants to use RateLimiter every 2 seconds. As soon as the RateLimiter is initialized, it starts checking if it has been 2 seconds since the time it was initialized. Currently, if a programmer wanted to make the RateLimiter restart its count at a specific part of the code, they would need to create a new RateLimiter object.

So, I added a public method that allows a RateLimiter's start time to be reset.


This change is Reviewable

dejabot
dejabot previously approved these changes Nov 30, 2023
Copy link
Contributor

@dejabot dejabot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Nice! For the extra mile, would you mind adding javadocs?

@1yd1a
Copy link
Contributor Author

1yd1a commented Nov 30, 2023

LGTM

Nice! For the extra mile, would you mind adding javadocs?

Done. I couldn't think of a more clear/concise description for the new method than "Resets the timer." I can add docs for the class and its other method, too.

@dejabot
Copy link
Contributor

dejabot commented Nov 30, 2023

Thx! Javadoc lg. And yeah it'd be great to have javadoc for the rest of the class - much appreciated. That could be a follow up PR too ofc.

Thx much!

@1yd1a 1yd1a merged commit 2331af6 into master Nov 30, 2023
6 checks passed
@1yd1a 1yd1a deleted the rateLimiterTweak branch November 30, 2023 06:54
dejabot pushed a commit that referenced this pull request Dec 30, 2023
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.

2 participants