-
Notifications
You must be signed in to change notification settings - Fork 387
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
fix(rate-limit): consider paused queue #1931
Conversation
local pttl = rcall("PTTL", rateLimiterKey) | ||
|
||
if pttl <= 0 then | ||
rcall("DEL", rateLimiterKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can delete the key here if it's 0
-- remove from active queue and add back to the wait list | ||
rcall("LREM", keys[2], 1, jobId) | ||
rcall("RPUSH", keys[1], jobId) | ||
rcall("RPUSH", targetKey, jobId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider paused queue, not only wait list
@@ -67,6 +67,11 @@ end | |||
if jobId then | |||
if string.sub(jobId, 1, 2) == "0:" then | |||
rcall("LREM", KEYS[2], 1, jobId) | |||
|
|||
if expireTime > 0 then | |||
return { 0, 0, expireTime, 0 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we delete the previous marker, if expireTime is greater than 0 (in rate-limit), we can return expireTime
}); | ||
}); | ||
|
||
await delay(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in order to get drained attribute as true for all workers
No description provided.