-
Notifications
You must be signed in to change notification settings - Fork 12
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
[FeatureRequest] support for queue per parameter value #2
Comments
Hello, The issue is that internally there is only one Queue object per middleware. Dynamic creation of queues is a bit more complex than it is now. Also the question is how to define |
The parameters are already parsed in the request object. Limiting could be done by matching parameters from an option value to the request parameters. Active limit could become an object for example: app.use(queue({ activeLimit: {limit: 2, params: ['something'] })); To limit only a changing app.use(queue({ activeLimit: {limit: 2, params: ['something', 'other'] })); In this case there should be probably a different queue for any When a queue is empty it can be destroyed to not take up too much memory for routes which may not be accessed any more. I would not got into the complexity of setting different limits for different parameters. |
It should not used globally in this way, but as a per route middleware. |
I don't know what use case you had in mind when you created this middleware. My use case was to limit access to one route which involved creation of a limited number of database artifacts. There I can't allow any concurrency since noSQL databases do not allow transactions and for every request I have to check if the item can be created. In a worst case when only one item is left to create there could come 2 or more requests at the same time and each get the answer that it is fine to create. I could involve redis for that matter but I was looking for a simple approach. |
For my api
/do/:something
I would like to allow only one request per value ofsomething
.For example:
/do/something
gets through/do/something
has to wait for first request to finish/do/somethingElse
gets throughThis is a simple example. The values for
something
are unspecified values likeuuid
s.The text was updated successfully, but these errors were encountered: