You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Since I have limited resources, I need to send 429 when the queue is being rate limited i.e when the set limit has been passed.
for example, I needed a function to help me write something like this:
let ttl = await queue.getRateLimitTtl();
if (ttl > 0) {
res.writeHead(429).end();
}
Initially, from reading the docs, I thought the function mentioned in the docsqueue.getRateLimitTtl() returns the ttl once the number of jobs have passed the limit that was initially set. Similar to the function getRateLimitTTL within the lua script here
This led to some confusion on my end when I started hitting 429 very often within the endpoint.
After having a deeper look, it seems like queue.getRateLimitTtl() shows ttl > 0 after a single job has been added to the queue within the duration.
Perhaps more clarification is need to be reflected with the docs
Also, maybe this is just me, but I fail to see the use case of the current behaviour of queue.getRateLimitTtl()
Describe the solution you'd like
A new class function for queue that is similar to the function getRateLimitTTL within the lua script here
( get ttl if and only if max jobs has been passed else 0)
update docs to reflect the difference between the two functions
Describe alternatives you've considered
I think I could run the lua script to get the ttl but I prefer if it was done gracefully via a class function in bullmq
If there any obvious alternatives I did not consider, sorry about that, I am fairly new to bullmq
The text was updated successfully, but these errors were encountered:
yashmasani
changed the title
getRateLimitTtl
feature/docs: getRateLimitTtl needs more details
Jun 30, 2024
Is your feature request related to a problem? Please describe.
Since I have limited resources, I need to send 429 when the queue is being rate limited i.e when the set limit has been passed.
for example, I needed a function to help me write something like this:
Initially, from reading the docs, I thought the function mentioned in the docs
queue.getRateLimitTtl()
returns the ttl once the number of jobs have passed the limit that was initially set. Similar to the functiongetRateLimitTTL
within the lua script hereThis led to some confusion on my end when I started hitting 429 very often within the endpoint.
After having a deeper look, it seems like
queue.getRateLimitTtl()
shows ttl > 0 after a single job has been added to the queue within the duration.Perhaps more clarification is need to be reflected with the docs
Also, maybe this is just me, but I fail to see the use case of the current behaviour of
queue.getRateLimitTtl()
Describe the solution you'd like
getRateLimitTTL
within the lua script here( get ttl if and only if max jobs has been passed else 0)
Describe alternatives you've considered
I think I could run the lua script to get the ttl but I prefer if it was done gracefully via a class function in bullmq
If there any obvious alternatives I did not consider, sorry about that, I am fairly new to bullmq
The text was updated successfully, but these errors were encountered: