-
Notifications
You must be signed in to change notification settings - Fork 419
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(job): add removeDependencyOnFail option #1100
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b53f9b6
feat(job): add removeDependencyOnFail option
roggervalf 0658553
chore: merge master
roggervalf a81ff7e
chore: fix test case
roggervalf 28d399a
style: remove extra space
roggervalf 8b6655e
refactor: check removeDependencyOnFail before remove dependency
roggervalf b99b381
chore: use elseif
roggervalf 721a0d4
perf(redis): transform opts property names
roggervalf 2c3c485
refactor: redisJobOptions as type
roggervalf dcbebd0
chore: merge master
roggervalf 516036b
chore: merge master
roggervalf 48206ba
refactor: rename updateParentIfNeeded to moveParentToWaitIfNeeded
roggervalf 978e732
chore: fix typo
roggervalf 243c4dc
docs(redis-job-options): add description
roggervalf 0db60cf
chore: merge branch master
roggervalf a3cadcc
chore: merge master
roggervalf f0a0765
refactor: replace argv param with opts attribute
roggervalf 28243a5
chore: merge master
roggervalf ae5a86e
chore: merge master
roggervalf 42bfea7
chore: import JobsOptions in test
roggervalf cf664aa
chore: fix merge conflicts
roggervalf 151805a
chore: merge master
roggervalf eba4ced
chore: merge master
roggervalf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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,17 @@ | ||
--[[ | ||
Validate and move parent to active if needed. | ||
]] | ||
|
||
-- Includes | ||
--- @include "getTargetQueueList" | ||
|
||
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentId ) | ||
local isParentActive = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId) | ||
if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then | ||
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) | ||
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait", parentQueueKey .. ":paused") | ||
rcall("RPUSH", parentTarget, parentId) | ||
|
||
rcall("XADD", parentQueueKey .. ":events", "*", "event", "active", "jobId", parentId, "prev", "waiting-children") | ||
end | ||
end |
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,20 +1,13 @@ | ||
--[[ | ||
Validate and move or add dependencies to parent. | ||
Add processed results, validate and move parent to active if needed. | ||
]] | ||
|
||
-- Includes | ||
--- @include "moveParentToWaitIfNeeded" | ||
|
||
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey, | ||
parentId, jobIdKey, returnvalue ) | ||
local processedSet = parentKey .. ":processed" | ||
rcall("HSET", processedSet, jobIdKey, returnvalue) | ||
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId) | ||
if rcall("SCARD", parentDependenciesKey) == 0 and activeParent then | ||
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) | ||
if rcall("HEXISTS", parentQueueKey .. ":meta", "paused") ~= 1 then | ||
rcall("RPUSH", parentQueueKey .. ":wait", parentId) | ||
else | ||
rcall("RPUSH", parentQueueKey .. ":paused", parentId) | ||
end | ||
|
||
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children") | ||
end | ||
moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentId ) | ||
end |
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './finished-status'; | ||
export * from './job-json-sandbox'; | ||
export * from './job-options'; | ||
export * from './job-type'; |
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,18 @@ | ||
import { BaseJobOptions } from '../interfaces'; | ||
|
||
export type JobsOptions = BaseJobOptions & { | ||
/** | ||
* If true, removes the job from its parent dependencies when it fails after all attempts. | ||
*/ | ||
removeDependencyOnFail?: boolean; | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a comment here clarifying that these fields are the ones stored in Redis and thus with smaller keys for compactness. |
||
/** | ||
* These fields are the ones stored in Redis with smaller keys for compactness. | ||
*/ | ||
export type RedisJobOptions = BaseJobOptions & { | ||
/** | ||
* If true, removes the job from its parent dependencies when it fails after all attempts. | ||
*/ | ||
rdof?: boolean; | ||
}; |
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.
Works for now but I guess in the future we will have a map object for translating all the options from Redis representation to library representation.
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.
yes, this is the beginning of it