Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(scripts): remove unnecessary false inequality validations #3117

Merged
merged 3 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions docs/gitbook/bullmq-pro/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
## [7.30.4](https://github.com/taskforcesh/bullmq-pro/compare/v7.30.3...v7.30.4) (2025-03-01)


### Bug Fixes

* **job-scheduler:** consider removing current job from wait, paused or prioritized ([#3066](https://github.com/taskforcesh/bullmq/issues/3066)) ([97cd2b1](https://github.com/taskforcesh/bullmq/commit/97cd2b147d541e0984d1c2e107110e1a9d56d9b5))


### Performance Improvements

* **delayed:** add marker once when promoting delayed jobs ([#3096](https://github.com/taskforcesh/bullmq/issues/3096)) (python) ([38912fb](https://github.com/taskforcesh/bullmq/commit/38912fba969d614eb44d05517ba2ec8bc418a16e))

## [7.30.3](https://github.com/taskforcesh/bullmq-pro/compare/v7.30.2...v7.30.3) (2025-02-21)


### Bug Fixes

* **repeat:** use JobPro class when creating delayed job ([#292](https://github.com/taskforcesh/bullmq-pro/issues/292)) ([ce9eff8](https://github.com/taskforcesh/bullmq-pro/commit/ce9eff8a7c000afb5bc23173267f44b2040a0c6a))
* **worker:** do not execute run method when no processor is defined when resuming ([#3089](https://github.com/taskforcesh/bullmq/issues/3089)) ([4a66933](https://github.com/taskforcesh/bullmq/commit/4a66933496db68a84ec7eb7c153fcedb7bd14c7b))
* **worker:** do not resume when closing ([#3080](https://github.com/taskforcesh/bullmq/issues/3080)) ([024ee0f](https://github.com/taskforcesh/bullmq/commit/024ee0f3f0e808c256712d3ccb1bcadb025eb931))
* **job:** set processedBy when moving job to active in moveToFinished ([#3077](https://github.com/taskforcesh/bullmq/issues/3077)) fixes [#3073](https://github.com/taskforcesh/bullmq/issues/3073) ([1aa970c](https://github.com/taskforcesh/bullmq/commit/1aa970ced3c55949aea6726c4ad29531089f5370))
* **drain:** pass delayed key for redis cluster ([#3074](https://github.com/taskforcesh/bullmq/issues/3074)) ([05ea32b](https://github.com/taskforcesh/bullmq/commit/05ea32b7e4f0cd4099783fd81d2b3214d7a293d5))
* **job-scheduler:** restore limit option to be saved ([#3071](https://github.com/taskforcesh/bullmq/issues/3071)) ([3e649f7](https://github.com/taskforcesh/bullmq/commit/3e649f7399514b343447ed2073cc07e4661f7390))
* **job-scheduler:** return undefined in getJobScheduler when it does not exist ([#3065](https://github.com/taskforcesh/bullmq/issues/3065)) fixes [#3062](https://github.com/taskforcesh/bullmq/issues/3062) ([548cc1c](https://github.com/taskforcesh/bullmq/commit/548cc1ce8080042b4b44009ea99108bd24193895))
* fix return type of getNextJob ([b970281](https://github.com/taskforcesh/bullmq/commit/b9702812e6961f0f5a834f66d43cfb2feabaafd8))


### Features

* **job:** add moveToWait method for manual processing ([#2978](https://github.com/taskforcesh/bullmq/issues/2978)) ([5a97491](https://github.com/taskforcesh/bullmq/commit/5a97491a0319df320b7858657e03c357284e0108))
* **queue:** support removeGlobalConcurrency method ([#3076](https://github.com/taskforcesh/bullmq/issues/3076)) ([ece8532](https://github.com/taskforcesh/bullmq/commit/ece853203adb420466dfaf3ff8bccc73fb917147))


### Performance Improvements

* **add-job:** add job into wait or prioritized state when delay is provided as 0 ([#3052](https://github.com/taskforcesh/bullmq/issues/3052)) ([3e990eb](https://github.com/taskforcesh/bullmq/commit/3e990eb742b3a12065110f33135f282711fdd7b9))

## [7.30.2](https://github.com/taskforcesh/bullmq-pro/compare/v7.30.1...v7.30.2) (2025-02-20)


### Bug Fixes

* **worker:** wait fetched jobs to be processed when closing ([#3059](https://github.com/taskforcesh/bullmq/issues/3059)) ([d4de2f5](https://github.com/taskforcesh/bullmq/commit/d4de2f5e88d57ea00274e62ab23d09f4806196f8))


## [7.30.1](https://github.com/taskforcesh/bullmq-pro/compare/v7.30.0...v7.30.1) (2025-02-20)


### Bug Fixes

* **job:** save processedBy attribute when preparing for processing ([#300](https://github.com/taskforcesh/bullmq-pro/issues/300)) ([c947f6e](https://github.com/taskforcesh/bullmq-pro/commit/c947f6eab80ecd7124e77a589e23f50909e0dee8))

# [7.30.0](https://github.com/taskforcesh/bullmq-pro/compare/v7.29.0...v7.30.0) (2025-02-19)


### Features

* **groups:** support local limiter options ([#262](https://github.com/taskforcesh/bullmq-pro/issues/262)) ([fed293c](https://github.com/taskforcesh/bullmq-pro/commit/fed293cceb575caa7be4987cb65c488faf700075))

# [7.29.0](https://github.com/taskforcesh/bullmq-pro/compare/v7.28.0...v7.29.0) (2025-02-18)


### Features

* **job-scheduler:** revert add delayed job and update in the same script ([9f0f1ba](https://github.com/taskforcesh/bullmq/commit/9f0f1ba9b17874a757ac38c1878792c0df3c5a9a))

# [7.28.0](https://github.com/taskforcesh/bullmq-pro/compare/v7.27.0...v7.28.0) (2025-02-15)


### Bug Fixes

* **worker:** evaluate if a job needs to be fetched when moving to failed ([#3043](https://github.com/taskforcesh/bullmq/issues/3043)) ([406e21c](https://github.com/taskforcesh/bullmq/commit/406e21c9aadd7670f353c1c6b102a401fc327653))
* **retry-job:** consider updating failures in job ([#3036](https://github.com/taskforcesh/bullmq/issues/3036)) ([21e8495](https://github.com/taskforcesh/bullmq/commit/21e8495b5f2bf5418d86f60b59fad25d306a0298))
* **flow-producer:** add support for skipWaitingForReady ([6d829fc](https://github.com/taskforcesh/bullmq/commit/6d829fceda9f204f193c533ffc780962692b8f16))


### Features

* **job-scheduler:** save limit option ([#3033](https://github.com/taskforcesh/bullmq/issues/3033)) ([a1571ea](https://github.com/taskforcesh/bullmq/commit/a1571ea03be6c6c41794fa272c38c29588351bbf))
* **queue:** add option to skip wait until connection ready ([e728299](https://github.com/taskforcesh/bullmq/commit/e72829922d4234b92290346dce5d33f5b98ee373))

# [7.27.0](https://github.com/taskforcesh/bullmq-pro/compare/v7.26.6...v7.27.0) (2025-02-12)


### Bug Fixes

* **worker:** avoid possible hazard in closing worker ([0f07467](https://github.com/taskforcesh/bullmq/commit/0f0746727176d7ff285ae2d1f35048109b4574c5))


### Features

* **queue-getters:** add prometheus exporter ([078ae9d](https://github.com/taskforcesh/bullmq/commit/078ae9db80f6ca64ff0a8135b57a6dc71d71cb1e))
* **job-scheduler:** save iteration count ([#3018](https://github.com/taskforcesh/bullmq/issues/3018)) ([ad5c07c](https://github.com/taskforcesh/bullmq/commit/ad5c07cc7672a3f7a7185310b1250763a5fef76b))
* **sandbox:** add support for getChildrenValues ([dcc3b06](https://github.com/taskforcesh/bullmq/commit/dcc3b0628f992546d7b93f509795e5d4eb3e1b15))

## [7.26.6](https://github.com/taskforcesh/bullmq-pro/compare/v7.26.5...v7.26.6) (2025-02-03)


### Bug Fixes

* **worker:** add missing otel trace when extending locks ([#290](https://github.com/taskforcesh/bullmq-pro/issues/290)) ([efbf948](https://github.com/taskforcesh/bullmq-pro/commit/efbf948585fee4614311db7789d4d351ecc87767))

## [7.26.5](https://github.com/taskforcesh/bullmq-pro/compare/v7.26.4...v7.26.5) (2025-02-02)


### Bug Fixes

* **worker:** remove the use of multi in extend locks ([3862075](https://github.com/taskforcesh/bullmq-pro/commit/3862075ab4e41cfa4c1f6b3f87ba50a5087f8c0d))

## [7.26.4](https://github.com/taskforcesh/bullmq-pro/compare/v7.26.3...v7.26.4) (2025-01-30)


### Bug Fixes

* **retry-job:** pass stalled key instead of limiter ([#291](https://github.com/taskforcesh/bullmq-pro/issues/291)) ([e981c69](https://github.com/taskforcesh/bullmq-pro/commit/e981c69067afa68f86be7599b3f835e53406dd9b))

## [7.26.3](https://github.com/taskforcesh/bullmq-pro/compare/v7.26.2...v7.26.3) (2025-01-26)


Expand Down
4 changes: 2 additions & 2 deletions src/commands/addRepeatableJob-2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ end
-- If we are overriding a repeatable job we must delete the delayed job for
-- the next iteration.
local prevMillis = rcall("ZSCORE", repeatKey, customKey)
if prevMillis ~= false then
if prevMillis then
local delayedJobId = "repeat:" .. customKey .. ":" .. prevMillis
local nextDelayedJobId = repeatKey .. ":" .. customKey .. ":" .. nextMillis

if rcall("ZSCORE", delayedKey, delayedJobId) ~= false
if rcall("ZSCORE", delayedKey, delayedJobId)
and rcall("EXISTS", nextDelayedJobId) ~= 1 then
removeJob(delayedJobId, true, prefixKey, true --[[remove debounce key]])
rcall("ZREM", delayedKey, delayedJobId)
Expand Down
10 changes: 5 additions & 5 deletions src/commands/getState-8.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
]]
local rcall = redis.call

if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[1], ARGV[1]) then
return "completed"
end

if rcall("ZSCORE", KEYS[2], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[2], ARGV[1]) then
return "failed"
end

if rcall("ZSCORE", KEYS[3], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[3], ARGV[1]) then
return "delayed"
end

if rcall("ZSCORE", KEYS[8], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[8], ARGV[1]) then
return "prioritized"
end

Expand All @@ -58,7 +58,7 @@ if checkItemInList(paused_items, ARGV[1]) ~= nil then
return "waiting"
end

if rcall("ZSCORE", KEYS[7], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[7], ARGV[1]) then
return "waiting-children"
end

Expand Down
16 changes: 8 additions & 8 deletions src/commands/getStateV2-8.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,35 @@
]]
local rcall = redis.call

if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[1], ARGV[1]) then
return "completed"
end

if rcall("ZSCORE", KEYS[2], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[2], ARGV[1]) then
return "failed"
end

if rcall("ZSCORE", KEYS[3], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[3], ARGV[1]) then
return "delayed"
end

if rcall("ZSCORE", KEYS[8], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[8], ARGV[1]) then
return "prioritized"
end

if rcall("LPOS", KEYS[4] , ARGV[1]) ~= false then
if rcall("LPOS", KEYS[4] , ARGV[1]) then
return "active"
end

if rcall("LPOS", KEYS[5] , ARGV[1]) ~= false then
if rcall("LPOS", KEYS[5] , ARGV[1]) then
return "waiting"
end

if rcall("LPOS", KEYS[6] , ARGV[1]) ~= false then
if rcall("LPOS", KEYS[6] , ARGV[1]) then
return "waiting"
end

if rcall("ZSCORE", KEYS[7] , ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[7] , ARGV[1]) then
return "waiting-children"
end

Expand Down
2 changes: 1 addition & 1 deletion src/commands/includes/isJobSchedulerJob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)
local repeatJobKey = rcall("HGET", jobKey, "rjk")
if repeatJobKey then
local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)
if prevMillis ~= false then
if prevMillis then
local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis
return jobId == currentDelayedJobId
end
Expand Down
2 changes: 1 addition & 1 deletion src/commands/includes/trimEvents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

local function trimEvents(metaKey, eventStreamKey)
local maxEvents = getOrSetMaxEvents(metaKey)
if maxEvents ~= false then
if maxEvents then
rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)
else
rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/includes/updateExistingJobsParent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local function updateExistingJobsParent(parentKey, parent, parentData,
parentDependenciesKey, completedKey,
jobIdKey, jobId, timestamp)
if parentKey ~= nil then
if rcall("ZSCORE", completedKey, jobId) ~= false then
if rcall("ZSCORE", completedKey, jobId) then
local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
updateParentDepsIfNeeded(parentKey, parent['queueKey'],
parentDependenciesKey, parent['id'],
Expand Down
4 changes: 2 additions & 2 deletions src/commands/isFinished-3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if rcall("EXISTS", KEYS[3]) ~= 1 then
return -1
end

if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[1], ARGV[1]) then
if ARGV[2] == "1" then
local returnValue = rcall("HGET", KEYS[3], "returnvalue")

Expand All @@ -32,7 +32,7 @@ if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
return 1
end

if rcall("ZSCORE", KEYS[2], ARGV[1]) ~= false then
if rcall("ZSCORE", KEYS[2], ARGV[1]) then
if ARGV[2] == "1" then
local failedReason = rcall("HGET", KEYS[3], "failedReason")

Expand Down
2 changes: 1 addition & 1 deletion src/commands/updateRepeatableJobMillis-1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local nextMillis = ARGV[1]
local customKey = ARGV[2]
local legacyCustomKey = ARGV[3]

if rcall("ZSCORE", repeatKey, customKey) ~= false then
if rcall("ZSCORE", repeatKey, customKey) then
rcall("ZADD", repeatKey, nextMillis, customKey)
return customKey
elseif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then
Expand Down
4 changes: 0 additions & 4 deletions tests/test_rate_limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ describe('Rate Limiter', function () {
'completed',
// after every job has been completed
after(numJobs, async () => {
await worker.close();

try {
const timeDiff = new Date().getTime() - startTime;
expect(timeDiff).to.be.gte((numJobs - 1) * 1000);
Expand Down Expand Up @@ -745,8 +743,6 @@ describe('Rate Limiter', function () {
'completed',
// after every job has been completed
after(numJobs, async args => {
await worker.close();

try {
expect(args.jobId).to.be.equal('1');
resolve();
Expand Down