bullmq 1.69.0 → 1.69.1

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.
@@ -46,15 +46,10 @@ local rcall = redis.call
46
46
  -- Includes
47
47
  --- @include "includes/updateParentDepsIfNeeded"
48
48
  --- @include "includes/destructureJobKey"
49
- --- @include "includes/removeParentDependencyKey"
49
+ --- @include "includes/removeJob"
50
50
 
51
51
  local jobIdKey = KEYS[3]
52
52
  if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
53
-
54
- if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
55
- return -4
56
- end
57
-
58
53
  if ARGV[10] ~= "0" then
59
54
  local lockKey = jobIdKey .. ':lock'
60
55
  if rcall("GET", lockKey) == ARGV[10] then
@@ -65,6 +60,10 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
65
60
  end
66
61
  end
67
62
 
63
+ if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
64
+ return -4
65
+ end
66
+
68
67
  local jobId = ARGV[1]
69
68
  local timestamp = ARGV[2]
70
69
 
@@ -116,25 +115,18 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
116
115
 
117
116
  -- Remove old jobs?
118
117
  local prefix = ARGV[9]
119
- local function removeJob(jobId)
120
- local jobKey = prefix .. jobId
121
- removeParentDependencyKey(jobKey)
122
- local jobLogKey = jobKey .. ':logs'
123
- local jobProcessedKey = jobKey .. ':processed'
124
- rcall("DEL", jobKey, jobLogKey, jobProcessedKey)
125
- end
126
118
 
127
119
  if maxAge ~= nil then
128
120
  local start = timestamp - maxAge * 1000
129
121
  local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
130
- for i, jobId in ipairs(jobIds) do removeJob(jobId) end
122
+ for i, jobId in ipairs(jobIds) do removeJob(jobId, false, prefix) end
131
123
  rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
132
124
  end
133
125
 
134
126
  if maxCount ~= nil and maxCount > 0 then
135
127
  local start = maxCount
136
128
  local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
137
- for i, jobId in ipairs(jobIds) do removeJob(jobId) end
129
+ for i, jobId in ipairs(jobIds) do removeJob(jobId, false, prefix) end
138
130
  rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
139
131
  end
140
132
  else
@@ -46,15 +46,10 @@ local rcall = redis.call
46
46
  -- Includes
47
47
  --- @include "includes/updateParentDepsIfNeeded"
48
48
  --- @include "includes/destructureJobKey"
49
- --- @include "includes/removeParentDependencyKey"
49
+ --- @include "includes/removeJob"
50
50
 
51
51
  local jobIdKey = KEYS[3]
52
52
  if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
53
-
54
- if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
55
- return -4
56
- end
57
-
58
53
  if ARGV[10] ~= "0" then
59
54
  local lockKey = jobIdKey .. ':lock'
60
55
  if rcall("GET", lockKey) == ARGV[10] then
@@ -65,6 +60,10 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
65
60
  end
66
61
  end
67
62
 
63
+ if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
64
+ return -4
65
+ end
66
+
68
67
  local jobId = ARGV[1]
69
68
  local timestamp = ARGV[2]
70
69
 
@@ -116,25 +115,18 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
116
115
 
117
116
  -- Remove old jobs?
118
117
  local prefix = ARGV[9]
119
- local function removeJob(jobId)
120
- local jobKey = prefix .. jobId
121
- removeParentDependencyKey(jobKey)
122
- local jobLogKey = jobKey .. ':logs'
123
- local jobProcessedKey = jobKey .. ':processed'
124
- rcall("DEL", jobKey, jobLogKey, jobProcessedKey)
125
- end
126
118
 
127
119
  if maxAge ~= nil then
128
120
  local start = timestamp - maxAge * 1000
129
121
  local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
130
- for i, jobId in ipairs(jobIds) do removeJob(jobId) end
122
+ for i, jobId in ipairs(jobIds) do removeJob(jobId, false, prefix) end
131
123
  rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
132
124
  end
133
125
 
134
126
  if maxCount ~= nil and maxCount > 0 then
135
127
  local start = maxCount
136
128
  local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
137
- for i, jobId in ipairs(jobIds) do removeJob(jobId) end
129
+ for i, jobId in ipairs(jobIds) do removeJob(jobId, false, prefix) end
138
130
  rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
139
131
  end
140
132
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bullmq",
3
- "version": "1.69.0",
3
+ "version": "1.69.1",
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",