-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(job-scheduler): add delayed job and scheduler in same script (#2993
- Loading branch information
1 parent
d1fb113
commit 95718e8
Showing
7 changed files
with
210 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { ChainableCommander } from 'ioredis'; | ||
import { debuglog } from 'util'; | ||
import { | ||
BackoffOptions, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--[[ | ||
Add marker if needed when a job is available. | ||
]] | ||
|
||
-- Includes | ||
--- @include "addDelayMarkerIfNeeded" | ||
--- @include "getDelayedScore" | ||
--- @include "storeJob" | ||
|
||
local function addDelayedJob(jobIdKey, jobId, delayedKey, eventsKey, name, data, opts, timestamp, repeatJobKey, | ||
maxEvents, markerKey, parentKey, parentData) | ||
-- Store the job. | ||
local delay, priority = storeJob(eventsKey, jobIdKey, jobId, name, data, | ||
opts, timestamp, parentKey, parentData, repeatJobKey) | ||
|
||
local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay)) | ||
|
||
rcall("ZADD", delayedKey, score, jobId) | ||
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed", | ||
"jobId", jobId, "delay", delayedTimestamp) | ||
|
||
-- mark that a delayed job is available | ||
addDelayMarkerIfNeeded(markerKey, delayedKey) | ||
end | ||
|
Oops, something went wrong.