-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(remove-job): consider removing parent dependency key in lua scrip…
…ts (#990)
- Loading branch information
1 parent
aea20b4
commit 661abf0
Showing
5 changed files
with
45 additions
and
31 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--[[ | ||
Check if this job has a parent. If so we will just remove it from | ||
the parent child list, but if it is the last child we should move the parent to "wait/paused" | ||
which requires code from "moveToFinished" | ||
]] | ||
|
||
--- @include "destructureJobKey" | ||
|
||
local function removeParentDependencyKey(jobKey) | ||
local parentKey = rcall("HGET", jobKey, "parentKey") | ||
if( (type(parentKey) == "string") and parentKey ~= "" and (rcall("EXISTS", parentKey) == 1)) then | ||
local parentDependenciesKey = parentKey .. ":dependencies" | ||
local result = rcall("SREM", parentDependenciesKey, jobKey) | ||
if result > 0 and rcall("SCARD", parentDependenciesKey) == 0 then | ||
local parentId = getJobIdFromKey(parentKey) | ||
local parentPrefix = getJobKeyPrefix(parentKey, parentId) | ||
|
||
rcall("ZREM", parentPrefix .. "waiting-children", parentId) | ||
|
||
if rcall("HEXISTS", parentPrefix .. "meta", "paused") ~= 1 then | ||
rcall("RPUSH", parentPrefix .. "wait", parentId) | ||
else | ||
rcall("RPUSH", parentPrefix .. "paused", parentId) | ||
end | ||
|
||
local parentEventStream = parentPrefix .. "events" | ||
rcall("XADD", parentEventStream, "*", "event", "active", "jobId", parentId, "prev", "waiting-children") | ||
end | ||
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
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