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

Block duration option for throttler #1668

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

asif-jalil
Copy link

@asif-jalil asif-jalil commented Sep 8, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently, when a user exceeds their request limit within a defined time window (ttl), their requests are blocked for a fixed duration tied to the ttl.

Issue Number: 1660

What is the new behavior?

I introduced a new option called blockDuration when importing the throttler module option. If users choose not to specify blockDuration, the system will fall back to the default behavior, which relies on the ttl.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@asif-jalil asif-jalil changed the title Issue/1660 Block duration option for throttler Sep 8, 2023
@jmcdo29
Copy link
Member

jmcdo29 commented Sep 8, 2023

From a quick pass it looks pretty good, I'll need to go more in depth later.

One main concern of mine is that this will be a breaking change at the library level, so anyone who maintains a storage package will need to update to the new interface.

Is there any way to keep the current API, or is hat not possible with the nature of the changes?

@asif-jalil
Copy link
Author

Yes. This will be a breaking change at the library level.

I think it's not possible to keep the current API.

@apmovamo
Copy link

apmovamo commented Dec 3, 2023

@jmcdo29 This would be nice to have

@cdx111
Copy link

cdx111 commented Feb 1, 2024

@asif-jalil I look forward to this feature

@asif-jalil
Copy link
Author

@asif-jalil I look forward to this feature

@cdx111 I also look forward to this feature. But I don't know why @jmcdo29 pushed this to a long waiting list!

@cdx111
Copy link

cdx111 commented Feb 2, 2024

@jmcdo29

@jmcdo29
Copy link
Member

jmcdo29 commented Feb 9, 2024

Apologies for the delay and thank you for your patience. It's been hectic keeping up with support and general life. I wanna revisit this and see what can be done with it, as I can tell there is a community want for this.

@asif-jalil
Copy link
Author

asif-jalil commented Feb 18, 2024

@jmcdo29 is there any update?

Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

All right! Finally got around to reviewing this. Overall everything looks good, there's a few changes I think I'll want to make as we're already going to be making breaking changes, so it'll be a good time to do so. I also want to get @kkoomen to take a look so he's aware of the changes that will need to be made for the redis storage for this update, but otherwise this looks good, and I'd be willing to release it soon

src/throttler.guard.ts Outdated Show resolved Hide resolved
src/throttler.guard.ts Outdated Show resolved Hide resolved
src/throttler.service.ts Outdated Show resolved Hide resolved
Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

okay, cool, code looks great. I'll let CI run, and wait for @kkoomen to weigh in as well

test/controller.e2e-spec.ts Outdated Show resolved Hide resolved
src/throttler-storage-options.interface.ts Outdated Show resolved Hide resolved
src/throttler-storage-options.interface.ts Outdated Show resolved Hide resolved
src/throttler-module-options.interface.ts Outdated Show resolved Hide resolved
src/throttler-storage-record.interface.ts Outdated Show resolved Hide resolved
src/throttler.guard.interface.ts Outdated Show resolved Hide resolved
src/throttler.guard.interface.ts Outdated Show resolved Hide resolved
src/throttler.guard.interface.ts Outdated Show resolved Hide resolved
@kkoomen
Copy link
Collaborator

kkoomen commented Feb 27, 2024

@jmcdo29 Sorry for my late reply, I'm very busy lately.

I only have some minor requests in terms of docblock things. I'm not too much involved in the project but it looks fine to me for what I see. I also noticed the ttl is sometimes in millisconds and seconds, which seems inconsistent, so make sure that it is milliseconds in the right places whenever it is being mentioned that they are in ms rather than secs.

Other than that, I don't think I need to make any adjustments to my redis storage, if so, someone will probably run into an issue and submit an issue :P

Copy link
Collaborator

@kkoomen kkoomen left a comment

Choose a reason for hiding this comment

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

Still some remaining typos and a console.log to be removed.

test/controller.e2e-spec.ts Outdated Show resolved Hide resolved
src/throttler-module-options.interface.ts Outdated Show resolved Hide resolved
src/throttler.guard.interface.ts Outdated Show resolved Hide resolved
@kkoomen
Copy link
Collaborator

kkoomen commented Feb 27, 2024

@jmcdo29 Looking good from my side. Up to you to merge whenever you feel like.

@asif-jalil
Copy link
Author

@jmcdo29 is there any update for merge?

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.

None yet

5 participants