| 1234567891011121314151617181920212223242526272829303132333435 |
- --[[
- Function to remove from any state.
- returns:
- prev state
- ]]
- local function removeJobFromAnyState( prefix, jobId)
- -- We start with the ZSCORE checks, since they have O(1) complexity
- if rcall("ZSCORE", prefix .. "completed", jobId) then
- rcall("ZREM", prefix .. "completed", jobId)
- return "completed"
- elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then
- rcall("ZREM", prefix .. "waiting-children", jobId)
- return "waiting-children"
- elseif rcall("ZSCORE", prefix .. "delayed", jobId) then
- rcall("ZREM", prefix .. "delayed", jobId)
- return "delayed"
- elseif rcall("ZSCORE", prefix .. "failed", jobId) then
- rcall("ZREM", prefix .. "failed", jobId)
- return "failed"
- elseif rcall("ZSCORE", prefix .. "prioritized", jobId) then
- rcall("ZREM", prefix .. "prioritized", jobId)
- return "prioritized"
- -- We remove only 1 element from the list, since we assume they are not added multiple times
- elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then
- return "wait"
- elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then
- return "paused"
- elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then
- return "active"
- end
- return "unknown"
- end
|