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
38
39
-- KEYS[1]: the active consumers set
-- KEYS[2]: the active job list
-- KEYS[3]: this consumer's inflight set
-- KEYS[4]: the job data hash
-- KEYS[5]: the signal list
-- ARGV[1]: the max number of jobs to get
-- ARGV[2]: this consumer's inflight set
-- Returns: the jobs
-- Ensure the consumer is registered
local registered = redis.
if not registered
-- Get the jobs out of the active job list
local job_ids = redis.
local count = table.
local results =
if count > 0
-- Signal to the other consumers to wait
if count < tonumber
return results