forked from seomoz/qless-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.lua
More file actions
37 lines (32 loc) · 1.13 KB
/
get.lua
File metadata and controls
37 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- This gets all the data associated with the job with the
-- provided id.
--
-- Args:
-- 1) jid
if #KEYS > 0 then error('Get(): No Keys should be provided') end
local jid = assert(ARGV[1], 'Get(): Arg "jid" missing')
-- Let's get all the data we can
local job = redis.call(
'hmget', 'ql:j:' .. jid, 'jid', 'klass', 'state', 'queue', 'worker', 'priority',
'expires', 'retries', 'remaining', 'data', 'tags', 'history', 'failure')
if not job[1] then
return false
end
return cjson.encode({
jid = job[1],
klass = job[2],
state = job[3],
queue = job[4],
worker = job[5] or '',
tracked = redis.call('zscore', 'ql:tracked', jid) ~= false,
priority = tonumber(job[6]),
expires = tonumber(job[7]) or 0,
retries = tonumber(job[8]),
remaining = tonumber(job[9]),
data = cjson.decode(job[10]),
tags = cjson.decode(job[11]),
history = cjson.decode(job[12]),
failure = cjson.decode(job[13] or '{}'),
dependents = redis.call('smembers', 'ql:j:' .. jid .. '-dependents'),
dependencies = redis.call('smembers', 'ql:j:' .. jid .. '-dependencies')
})