-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Question about precise-memory-ratelimit #316
Comments
You could get the So in your const getMax = typeof options.max === 'function'
? options.max(request, response)
: options.max
this.max = await getMax And then remove the same line from your constructor. |
@gamemaker1 I don't think that would work, as @Nebulizer1213 I think this would require a change to the store API, to either pass in the Can you give me more context on what ValueDeterminingMiddleWare is? Why would increment need to know the max value? |
@nfriedly I need the max in the incr function because if the user's request exceeds the max, the timestamp for the user should not change.
|
I'm pretty sure the other stores use the fixed window algorithm by setting an expiry on the first request. This would not work for me because I use the token bucket algorithm. |
Ok, I've been thinking about this. I think we should just add I don't think this will break any existing stores, but I'd like to check to be sure. If necessary, we could add a way for stores to opt into this behavior. |
Description
Is there a way to get the request and response from inside of the increment function, so I can get the max if they use the ValueDeterminingMiddleWare?
I have this, but it only works if they use a number for max
Library version
6.5.1
Node version
v18.4.0
Typescript version (if you are using it)
v4.7.4
Module system
ESM
The text was updated successfully, but these errors were encountered: