-
Notifications
You must be signed in to change notification settings - Fork 359
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
feat(worker): add discardTtl option #1653
Open
roggervalf
wants to merge
8
commits into
master
Choose a base branch
from
feat-discard-ttl
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c3b7ba0
feat(worker): add discardTtl option
roggervalf 0c2df1f
test(discard-ttl): add test case when removeOnFail is provided
roggervalf 68b87bd
chore: merge branch 'master' into feat-discard-ttl
roggervalf 96be83f
refactor: clarify test cases
roggervalf 22554d3
chore: fix merge conflicts
roggervalf 74df17b
refactor(discard-job): remove job after ttl
roggervalf 2121a64
chore: remove extra error message
roggervalf c8b4edb
chore: fix merge conflicts
roggervalf File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--[[ | ||
Removes job from queue after ttl. | ||
|
||
Input: | ||
KEYS[1] 'active', | ||
KEYS[2] 'wait' | ||
KEYS[3] 'paused' | ||
KEYS[4] job key | ||
KEYS[5] 'meta' | ||
KEYS[6] events stream | ||
KEYS[7] delayed key | ||
KEYS[8] priority key | ||
|
||
ARGV[1] key prefix | ||
ARGV[2] timestamp | ||
ARGV[3] jobId | ||
ARGV[4] token | ||
|
||
Events: | ||
'waiting' | ||
|
||
Output: | ||
0 - OK | ||
-1 - Missing key | ||
-2 - Missing lock | ||
]] | ||
local rcall = redis.call | ||
|
||
-- Includes | ||
--- @include "includes/getTargetQueueList" | ||
--- @include "includes/promoteDelayedJobs" | ||
--- @include "includes/removeJob" | ||
|
||
promoteDelayedJobs(KEYS[7], KEYS[2], KEYS[8], KEYS[3], KEYS[5], KEYS[6], ARGV[1], ARGV[2]) | ||
|
||
if rcall("EXISTS", KEYS[4]) == 1 then | ||
|
||
if ARGV[4] ~= "0" then | ||
local lockKey = KEYS[4] .. ':lock' | ||
if rcall("GET", lockKey) == ARGV[4] then | ||
rcall("DEL", lockKey) | ||
else | ||
return -2 | ||
end | ||
end | ||
|
||
local target = getTargetQueueList(KEYS[5], KEYS[2], KEYS[3]) | ||
|
||
rcall("LREM", KEYS[1], 0, ARGV[3]) | ||
removeJob(ARGV[3], false, ARGV[1]) | ||
|
||
-- Emit discarded event | ||
rcall("XADD", KEYS[6], "*", "event", "discarded", "jobId", ARGV[3], "prev", "active"); | ||
|
||
return 0 | ||
else | ||
return -1 | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum ErrorMessages { | ||
RATE_LIMIT = 'bullmq:rateLimitExceeded', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './error-code.enum'; | ||
export * from './error-code'; | ||
export * from './error-messages'; | ||
export * from './metrics-time'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what about this
err.name
no need to also change tomessage
?