bullmq 3.5.3 → 3.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,20 +6,26 @@
6
6
  ]]
7
7
 
8
8
  local function removeJobFromAnyState( prefix, jobId)
9
- if rcall("LREM", prefix .. "wait", 0, jobId) == 1 then
10
- return "wait"
11
- elseif rcall("LREM", prefix .. "paused", 0, jobId) == 1 then
12
- return "paused"
13
- elseif rcall("LREM", prefix .. "active", 0, jobId) == 1 then
14
- return "active"
15
- elseif rcall("ZREM", prefix .. "waiting-children", jobId) == 1 then
9
+ -- We start with the ZSCORE checks, since they have O(1) complexity
10
+ if rcall("ZSCORE", prefix .. "completed", jobId) then
11
+ rcall("ZREM", prefix .. "completed", jobId)
12
+ return "completed"
13
+ elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then
14
+ rcall("ZREM", prefix .. "waiting-children", jobId)
16
15
  return "waiting-children"
17
- elseif rcall("ZREM", prefix .. "delayed", jobId) == 1 then
16
+ elseif rcall("ZSCORE", prefix .. "delayed", jobId) then
17
+ rcall("ZREM", prefix .. "delayed", jobId)
18
18
  return "delayed"
19
- elseif rcall("ZREM", prefix .. "completed", jobId) == 1 then
20
- return "completed"
21
- elseif rcall("ZREM", prefix .. "failed", jobId) == 1 then
19
+ elseif rcall("ZSCORE", prefix .. "failed", jobId) then
20
+ rcall("ZREM", prefix .. "failed", jobId)
22
21
  return "failed"
22
+ -- We remove only 1 element from the list, since we assume they are not added multiple times
23
+ elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then
24
+ return "wait"
25
+ elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then
26
+ return "paused"
27
+ elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then
28
+ return "active"
23
29
  end
24
30
 
25
31
  return "unknown"
@@ -56,20 +56,26 @@ end
56
56
  prev state
57
57
  ]]
58
58
  local function removeJobFromAnyState( prefix, jobId)
59
- if rcall("LREM", prefix .. "wait", 0, jobId) == 1 then
60
- return "wait"
61
- elseif rcall("LREM", prefix .. "paused", 0, jobId) == 1 then
62
- return "paused"
63
- elseif rcall("LREM", prefix .. "active", 0, jobId) == 1 then
64
- return "active"
65
- elseif rcall("ZREM", prefix .. "waiting-children", jobId) == 1 then
59
+ -- We start with the ZSCORE checks, since they have O(1) complexity
60
+ if rcall("ZSCORE", prefix .. "completed", jobId) then
61
+ rcall("ZREM", prefix .. "completed", jobId)
62
+ return "completed"
63
+ elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then
64
+ rcall("ZREM", prefix .. "waiting-children", jobId)
66
65
  return "waiting-children"
67
- elseif rcall("ZREM", prefix .. "delayed", jobId) == 1 then
66
+ elseif rcall("ZSCORE", prefix .. "delayed", jobId) then
67
+ rcall("ZREM", prefix .. "delayed", jobId)
68
68
  return "delayed"
69
- elseif rcall("ZREM", prefix .. "completed", jobId) == 1 then
70
- return "completed"
71
- elseif rcall("ZREM", prefix .. "failed", jobId) == 1 then
69
+ elseif rcall("ZSCORE", prefix .. "failed", jobId) then
70
+ rcall("ZREM", prefix .. "failed", jobId)
72
71
  return "failed"
72
+ -- We remove only 1 element from the list, since we assume they are not added multiple times
73
+ elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then
74
+ return "wait"
75
+ elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then
76
+ return "paused"
77
+ elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then
78
+ return "active"
73
79
  end
74
80
  return "unknown"
75
81
  end
@@ -1 +1 @@
1
- {"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoMf,CAAC;AACW,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Mf,CAAC;AACW,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -6,20 +6,26 @@
6
6
  ]]
7
7
 
8
8
  local function removeJobFromAnyState( prefix, jobId)
9
- if rcall("LREM", prefix .. "wait", 0, jobId) == 1 then
10
- return "wait"
11
- elseif rcall("LREM", prefix .. "paused", 0, jobId) == 1 then
12
- return "paused"
13
- elseif rcall("LREM", prefix .. "active", 0, jobId) == 1 then
14
- return "active"
15
- elseif rcall("ZREM", prefix .. "waiting-children", jobId) == 1 then
9
+ -- We start with the ZSCORE checks, since they have O(1) complexity
10
+ if rcall("ZSCORE", prefix .. "completed", jobId) then
11
+ rcall("ZREM", prefix .. "completed", jobId)
12
+ return "completed"
13
+ elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then
14
+ rcall("ZREM", prefix .. "waiting-children", jobId)
16
15
  return "waiting-children"
17
- elseif rcall("ZREM", prefix .. "delayed", jobId) == 1 then
16
+ elseif rcall("ZSCORE", prefix .. "delayed", jobId) then
17
+ rcall("ZREM", prefix .. "delayed", jobId)
18
18
  return "delayed"
19
- elseif rcall("ZREM", prefix .. "completed", jobId) == 1 then
20
- return "completed"
21
- elseif rcall("ZREM", prefix .. "failed", jobId) == 1 then
19
+ elseif rcall("ZSCORE", prefix .. "failed", jobId) then
20
+ rcall("ZREM", prefix .. "failed", jobId)
22
21
  return "failed"
22
+ -- We remove only 1 element from the list, since we assume they are not added multiple times
23
+ elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then
24
+ return "wait"
25
+ elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then
26
+ return "paused"
27
+ elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then
28
+ return "active"
23
29
  end
24
30
 
25
31
  return "unknown"
@@ -53,20 +53,26 @@ end
53
53
  prev state
54
54
  ]]
55
55
  local function removeJobFromAnyState( prefix, jobId)
56
- if rcall("LREM", prefix .. "wait", 0, jobId) == 1 then
57
- return "wait"
58
- elseif rcall("LREM", prefix .. "paused", 0, jobId) == 1 then
59
- return "paused"
60
- elseif rcall("LREM", prefix .. "active", 0, jobId) == 1 then
61
- return "active"
62
- elseif rcall("ZREM", prefix .. "waiting-children", jobId) == 1 then
56
+ -- We start with the ZSCORE checks, since they have O(1) complexity
57
+ if rcall("ZSCORE", prefix .. "completed", jobId) then
58
+ rcall("ZREM", prefix .. "completed", jobId)
59
+ return "completed"
60
+ elseif rcall("ZSCORE", prefix .. "waiting-children", jobId) then
61
+ rcall("ZREM", prefix .. "waiting-children", jobId)
63
62
  return "waiting-children"
64
- elseif rcall("ZREM", prefix .. "delayed", jobId) == 1 then
63
+ elseif rcall("ZSCORE", prefix .. "delayed", jobId) then
64
+ rcall("ZREM", prefix .. "delayed", jobId)
65
65
  return "delayed"
66
- elseif rcall("ZREM", prefix .. "completed", jobId) == 1 then
67
- return "completed"
68
- elseif rcall("ZREM", prefix .. "failed", jobId) == 1 then
66
+ elseif rcall("ZSCORE", prefix .. "failed", jobId) then
67
+ rcall("ZREM", prefix .. "failed", jobId)
69
68
  return "failed"
69
+ -- We remove only 1 element from the list, since we assume they are not added multiple times
70
+ elseif rcall("LREM", prefix .. "wait", 1, jobId) == 1 then
71
+ return "wait"
72
+ elseif rcall("LREM", prefix .. "paused", 1, jobId) == 1 then
73
+ return "paused"
74
+ elseif rcall("LREM", prefix .. "active", 1, jobId) == 1 then
75
+ return "active"
70
76
  end
71
77
  return "unknown"
72
78
  end
@@ -1 +1 @@
1
- {"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoMf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Mf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bullmq",
3
- "version": "3.5.3",
3
+ "version": "3.5.4",
4
4
  "description": "Queue for messages and jobs based on Redis",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",