@tachybase/plugin-adapter-bullmq 1.3.17 → 1.3.18
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.
- package/dist/externalVersion.js +2 -2
- package/dist/node_modules/@bull-board/api/dist/src/handlers/error.d.ts +4 -2
- package/dist/node_modules/@bull-board/api/dist/src/handlers/error.js +2 -2
- package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseAll.d.ts +4 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseAll.js +15 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/queues.js +4 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeAll.d.ts +4 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeAll.js +15 -0
- package/dist/node_modules/@bull-board/api/dist/src/index.js +1 -1
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.d.ts +4 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.js +6 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bull.js +6 -4
- package/dist/node_modules/@bull-board/api/dist/src/routes.js +4 -0
- package/dist/node_modules/@bull-board/api/dist/typings/app.d.ts +22 -2
- package/dist/node_modules/@bull-board/api/package.json +1 -1
- package/dist/node_modules/@bull-board/koa/dist/KoaAdapter.js +1 -1
- package/dist/node_modules/@bull-board/koa/dist/index.js +101 -101
- package/dist/node_modules/@bull-board/koa/package.json +1 -1
- package/dist/node_modules/bullmq/dist/cjs/classes/backoffs.js +18 -5
- package/dist/node_modules/bullmq/dist/cjs/classes/child-pool.js +7 -2
- package/dist/node_modules/bullmq/dist/cjs/classes/child-processor.js +59 -5
- package/dist/node_modules/bullmq/dist/cjs/classes/child.js +3 -1
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/index.js +2 -1
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/waiting-error.js +19 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/flow-producer.js +21 -5
- package/dist/node_modules/bullmq/dist/cjs/classes/index.js +1 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/job-scheduler.js +88 -62
- package/dist/node_modules/bullmq/dist/cjs/classes/job.js +216 -109
- package/dist/node_modules/bullmq/dist/cjs/classes/main-base.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-base.js +10 -9
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-getters.js +34 -14
- package/dist/node_modules/bullmq/dist/cjs/classes/queue.js +19 -13
- package/dist/node_modules/bullmq/dist/cjs/classes/redis-connection.js +16 -9
- package/dist/node_modules/bullmq/dist/cjs/classes/repeat.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/classes/sandbox.js +54 -28
- package/dist/node_modules/bullmq/dist/cjs/classes/scripts.js +141 -39
- package/dist/node_modules/bullmq/dist/cjs/classes/worker.js +191 -182
- package/dist/node_modules/bullmq/dist/cjs/commands/addDelayedJob-6.lua +6 -17
- package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-11.lua +123 -0
- package/dist/node_modules/bullmq/dist/{esm/commands/addParentJob-4.lua → cjs/commands/addParentJob-5.lua} +7 -6
- package/dist/node_modules/bullmq/dist/cjs/commands/{addPrioritizedJob-8.lua → addPrioritizedJob-9.lua} +11 -10
- package/dist/node_modules/bullmq/dist/cjs/commands/addRepeatableJob-2.lua +2 -2
- package/dist/node_modules/bullmq/dist/{esm/commands/addStandardJob-8.lua → cjs/commands/addStandardJob-9.lua} +9 -8
- package/dist/node_modules/bullmq/dist/cjs/commands/cleanJobsInSet-3.lua +9 -5
- package/dist/node_modules/bullmq/dist/cjs/commands/drain-5.lua +16 -16
- package/dist/node_modules/bullmq/dist/cjs/commands/getDependencyCounts-4.lua +31 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getState-8.lua +5 -5
- package/dist/node_modules/bullmq/dist/cjs/commands/getStateV2-8.lua +8 -8
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addDelayedJob.lua +23 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobFromScheduler.lua +37 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobWithPriority.lua +2 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanList.lua +4 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanSet.lua +3 -11
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/collectMetrics.lua +1 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/deduplicateJob.lua +63 -18
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/filterOutJobsToIgnore.lua +14 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +1 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getOrSetMaxEvents.lua +6 -6
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getPriorityScore.lua +8 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/isJobSchedulerJob.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/isLocked.lua +1 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +77 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/{moveJobFromPriorityToActive.lua → moveJobFromPrioritizedToActive.lua} +1 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWait.lua +45 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/prepareJobForProcessing.lua +2 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -3
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJob.lua +2 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobKeys.lua +2 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobWithChildren.lua +95 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeListJobs.lua +7 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeParentDependencyKey.lua +5 -5
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeZSetJobs.lua +2 -8
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJob.lua +2 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJobScheduler.lua +52 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/trimEvents.lua +1 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateExistingJobsParent.lua +1 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateJobFields.lua +5 -5
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/isFinished-3.lua +2 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-9.lua +63 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-8.lua +109 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToActive-11.lua +3 -2
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToFinished-14.lua +52 -52
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-8.lua +106 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/removeJob-2.lua +18 -66
- package/dist/node_modules/bullmq/dist/cjs/commands/removeJobScheduler-3.lua +1 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/removeUnprocessedChildren-2.lua +31 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/retryJob-11.lua +11 -5
- package/dist/node_modules/bullmq/dist/cjs/commands/updateJobScheduler-12.lua +90 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/updateRepeatableJobMillis-1.lua +1 -1
- package/dist/node_modules/bullmq/dist/cjs/enums/child-command.js +2 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/error-code.js +2 -1
- package/dist/node_modules/bullmq/dist/cjs/enums/parent-command.js +5 -2
- package/dist/node_modules/bullmq/dist/cjs/index.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/interfaces/index.js +2 -1
- package/dist/node_modules/bullmq/dist/cjs/interfaces/{debounce-options.js → parent-options.js} +1 -1
- package/dist/node_modules/bullmq/dist/cjs/interfaces/receiver.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addDelayedJob-6.js +163 -84
- package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-11.js +465 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/{addParentJob-4.js → addParentJob-5.js} +147 -75
- package/dist/node_modules/bullmq/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-9.js} +151 -79
- package/dist/node_modules/bullmq/dist/cjs/scripts/addRepeatableJob-2.js +18 -13
- package/dist/node_modules/bullmq/dist/cjs/scripts/{addStandardJob-8.js → addStandardJob-9.js} +149 -77
- package/dist/node_modules/bullmq/dist/cjs/scripts/changeDelay-4.js +7 -7
- package/dist/node_modules/bullmq/dist/cjs/scripts/changePriority-7.js +8 -2
- package/dist/node_modules/bullmq/dist/cjs/scripts/cleanJobsInSet-3.js +45 -29
- package/dist/node_modules/bullmq/dist/cjs/scripts/drain-5.js +49 -35
- package/dist/node_modules/bullmq/dist/cjs/scripts/getDependencyCounts-4.js +37 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getState-8.js +5 -5
- package/dist/node_modules/bullmq/dist/cjs/scripts/getStateV2-8.js +8 -8
- package/dist/node_modules/bullmq/dist/cjs/scripts/index.js +10 -7
- package/dist/node_modules/bullmq/dist/cjs/scripts/isFinished-3.js +2 -2
- package/dist/node_modules/bullmq/dist/cjs/scripts/{moveJobFromActiveToWait-10.js → moveJobFromActiveToWait-9.js} +57 -37
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobsToWait-8.js +6 -6
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-8.js +171 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToActive-11.js +18 -8
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToDelayed-8.js +12 -12
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToFinished-14.js +218 -155
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-8.js +529 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/obliterate-2.js +33 -20
- package/dist/node_modules/bullmq/dist/cjs/scripts/pause-7.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/promote-9.js +8 -2
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeChildDependency-1.js +7 -7
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeJob-2.js +120 -63
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeJobScheduler-3.js +3 -3
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeRepeatable-3.js +2 -2
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeUnprocessedChildren-2.js +339 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/reprocessJob-8.js +6 -6
- package/dist/node_modules/bullmq/dist/cjs/scripts/retryJob-11.js +47 -26
- package/dist/node_modules/bullmq/dist/cjs/scripts/updateJobScheduler-12.js +274 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/updateProgress-3.js +6 -6
- package/dist/node_modules/bullmq/dist/cjs/scripts/updateRepeatableJobMillis-1.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/node_modules/bullmq/dist/cjs/types/deduplication-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/index.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/job-progress.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/script-queue-context.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/utils.js +29 -1
- package/dist/node_modules/bullmq/dist/cjs/version.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/backoffs.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/backoffs.js +18 -5
- package/dist/node_modules/bullmq/dist/esm/classes/child-pool.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/child-pool.js +7 -2
- package/dist/node_modules/bullmq/dist/esm/classes/child-processor.d.ts +3 -2
- package/dist/node_modules/bullmq/dist/esm/classes/child-processor.js +59 -5
- package/dist/node_modules/bullmq/dist/esm/classes/child.js +3 -1
- package/dist/node_modules/bullmq/dist/esm/classes/errors/index.d.ts +2 -1
- package/dist/node_modules/bullmq/dist/esm/classes/errors/index.js +2 -1
- package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-error.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-error.js +15 -0
- package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.d.ts +3 -9
- package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.js +21 -5
- package/dist/node_modules/bullmq/dist/esm/classes/index.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/esm/classes/index.js +1 -0
- package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.d.ts +2 -2
- package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.js +88 -62
- package/dist/node_modules/bullmq/dist/esm/classes/job.d.ts +69 -19
- package/dist/node_modules/bullmq/dist/esm/classes/job.js +217 -110
- package/dist/node_modules/bullmq/dist/esm/classes/main-base.d.ts +2 -3
- package/dist/node_modules/bullmq/dist/esm/classes/main-base.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/queue-base.d.ts +2 -5
- package/dist/node_modules/bullmq/dist/esm/classes/queue-base.js +11 -10
- package/dist/node_modules/bullmq/dist/esm/classes/queue-events-producer.d.ts +2 -2
- package/dist/node_modules/bullmq/dist/esm/classes/queue-events.d.ts +118 -29
- package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.d.ts +20 -13
- package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.js +34 -14
- package/dist/node_modules/bullmq/dist/esm/classes/queue.d.ts +19 -16
- package/dist/node_modules/bullmq/dist/esm/classes/queue.js +19 -13
- package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.d.ts +7 -3
- package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.js +16 -9
- package/dist/node_modules/bullmq/dist/esm/classes/repeat.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/sandbox.js +54 -28
- package/dist/node_modules/bullmq/dist/esm/classes/scripts.d.ts +20 -13
- package/dist/node_modules/bullmq/dist/esm/classes/scripts.js +141 -39
- package/dist/node_modules/bullmq/dist/esm/classes/worker.d.ts +28 -7
- package/dist/node_modules/bullmq/dist/esm/classes/worker.js +192 -183
- package/dist/node_modules/bullmq/dist/esm/commands/addDelayedJob-6.lua +6 -17
- package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-11.lua +123 -0
- package/dist/node_modules/bullmq/dist/{cjs/commands/addParentJob-4.lua → esm/commands/addParentJob-5.lua} +7 -6
- package/dist/node_modules/bullmq/dist/esm/commands/{addPrioritizedJob-8.lua → addPrioritizedJob-9.lua} +11 -10
- package/dist/node_modules/bullmq/dist/esm/commands/addRepeatableJob-2.lua +2 -2
- package/dist/node_modules/bullmq/dist/{cjs/commands/addStandardJob-8.lua → esm/commands/addStandardJob-9.lua} +9 -8
- package/dist/node_modules/bullmq/dist/esm/commands/cleanJobsInSet-3.lua +9 -5
- package/dist/node_modules/bullmq/dist/esm/commands/drain-5.lua +16 -16
- package/dist/node_modules/bullmq/dist/esm/commands/getDependencyCounts-4.lua +31 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getState-8.lua +5 -5
- package/dist/node_modules/bullmq/dist/esm/commands/getStateV2-8.lua +8 -8
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addDelayedJob.lua +23 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobFromScheduler.lua +37 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobWithPriority.lua +2 -2
- package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanList.lua +4 -2
- package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanSet.lua +3 -11
- package/dist/node_modules/bullmq/dist/esm/commands/includes/collectMetrics.lua +1 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/deduplicateJob.lua +63 -18
- package/dist/node_modules/bullmq/dist/esm/commands/includes/filterOutJobsToIgnore.lua +14 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getNextDelayedTimestamp.lua +1 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getOrSetMaxEvents.lua +6 -6
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getPriorityScore.lua +8 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/isJobSchedulerJob.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/isLocked.lua +1 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +77 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/{moveJobFromPriorityToActive.lua → moveJobFromPrioritizedToActive.lua} +1 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWait.lua +45 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/prepareJobForProcessing.lua +2 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -3
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJob.lua +2 -2
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobKeys.lua +2 -2
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobWithChildren.lua +95 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeListJobs.lua +7 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeParentDependencyKey.lua +5 -5
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeZSetJobs.lua +2 -8
- package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJob.lua +2 -2
- package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJobScheduler.lua +52 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/trimEvents.lua +1 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/updateExistingJobsParent.lua +1 -1
- package/dist/node_modules/bullmq/dist/esm/commands/includes/updateJobFields.lua +5 -5
- package/dist/node_modules/bullmq/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
- package/dist/node_modules/bullmq/dist/esm/commands/isFinished-3.lua +2 -2
- package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-9.lua +63 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-8.lua +109 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveToActive-11.lua +3 -2
- package/dist/node_modules/bullmq/dist/esm/commands/moveToFinished-14.lua +52 -52
- package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-8.lua +106 -0
- package/dist/node_modules/bullmq/dist/esm/commands/removeJob-2.lua +18 -66
- package/dist/node_modules/bullmq/dist/esm/commands/removeJobScheduler-3.lua +1 -1
- package/dist/node_modules/bullmq/dist/esm/commands/removeUnprocessedChildren-2.lua +31 -0
- package/dist/node_modules/bullmq/dist/esm/commands/retryJob-11.lua +11 -5
- package/dist/node_modules/bullmq/dist/esm/commands/updateJobScheduler-12.lua +90 -0
- package/dist/node_modules/bullmq/dist/esm/commands/updateRepeatableJobMillis-1.lua +1 -1
- package/dist/node_modules/bullmq/dist/esm/enums/child-command.d.ts +3 -1
- package/dist/node_modules/bullmq/dist/esm/enums/child-command.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.d.ts +3 -2
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.js +2 -1
- package/dist/node_modules/bullmq/dist/esm/enums/parent-command.d.ts +5 -2
- package/dist/node_modules/bullmq/dist/esm/enums/parent-command.js +5 -2
- package/dist/node_modules/bullmq/dist/esm/interfaces/backoff-options.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/base-job-options.d.ts +3 -9
- package/dist/node_modules/bullmq/dist/esm/interfaces/child-message.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/index.d.ts +2 -1
- package/dist/node_modules/bullmq/dist/esm/interfaces/index.js +2 -1
- package/dist/node_modules/bullmq/dist/esm/interfaces/job-json.d.ts +6 -2
- package/dist/node_modules/bullmq/dist/esm/interfaces/job-scheduler-json.d.ts +7 -4
- package/dist/node_modules/bullmq/dist/esm/interfaces/minimal-job.d.ts +34 -15
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent-options.d.ts +11 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent.d.ts +6 -2
- package/dist/node_modules/bullmq/dist/esm/interfaces/queue-options.d.ts +15 -6
- package/dist/node_modules/bullmq/dist/esm/interfaces/receiver.d.ts +4 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/receiver.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeat-options.d.ts +1 -2
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-options.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job.d.ts +3 -2
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-options.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/interfaces/telemetry.d.ts +18 -15
- package/dist/node_modules/bullmq/dist/esm/interfaces/worker-options.d.ts +10 -10
- package/dist/node_modules/bullmq/dist/esm/scripts/addDelayedJob-6.js +163 -84
- package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-11.js +462 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/{addParentJob-4.js → addParentJob-5.js} +147 -75
- package/dist/node_modules/bullmq/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-9.js} +151 -79
- package/dist/node_modules/bullmq/dist/esm/scripts/addRepeatableJob-2.js +18 -13
- package/dist/node_modules/bullmq/dist/esm/scripts/{addStandardJob-8.js → addStandardJob-9.js} +149 -77
- package/dist/node_modules/bullmq/dist/esm/scripts/changeDelay-4.js +7 -7
- package/dist/node_modules/bullmq/dist/esm/scripts/changePriority-7.js +8 -2
- package/dist/node_modules/bullmq/dist/esm/scripts/cleanJobsInSet-3.js +45 -29
- package/dist/node_modules/bullmq/dist/esm/scripts/drain-5.js +49 -35
- package/dist/node_modules/bullmq/dist/esm/scripts/getDependencyCounts-4.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getDependencyCounts-4.js +34 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getState-8.js +5 -5
- package/dist/node_modules/bullmq/dist/esm/scripts/getStateV2-8.js +8 -8
- package/dist/node_modules/bullmq/dist/esm/scripts/index.d.ts +10 -7
- package/dist/node_modules/bullmq/dist/esm/scripts/index.js +10 -7
- package/dist/node_modules/bullmq/dist/esm/scripts/isFinished-3.js +2 -2
- package/dist/node_modules/bullmq/dist/esm/scripts/{moveJobFromActiveToWait-10.js → moveJobFromActiveToWait-9.js} +57 -37
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobsToWait-8.js +6 -6
- package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-8.js +168 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToActive-11.js +18 -8
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToDelayed-8.js +12 -12
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToFinished-14.js +218 -155
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-8.js +526 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/obliterate-2.js +33 -20
- package/dist/node_modules/bullmq/dist/esm/scripts/pause-7.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/promote-9.js +8 -2
- package/dist/node_modules/bullmq/dist/esm/scripts/removeChildDependency-1.js +7 -7
- package/dist/node_modules/bullmq/dist/esm/scripts/removeJob-2.js +120 -63
- package/dist/node_modules/bullmq/dist/esm/scripts/removeJobScheduler-3.js +3 -3
- package/dist/node_modules/bullmq/dist/esm/scripts/removeRepeatable-3.js +2 -2
- package/dist/node_modules/bullmq/dist/esm/scripts/removeUnprocessedChildren-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeUnprocessedChildren-2.js +336 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/reprocessJob-8.js +6 -6
- package/dist/node_modules/bullmq/dist/esm/scripts/retryJob-11.js +47 -26
- package/dist/node_modules/bullmq/dist/esm/scripts/updateJobScheduler-12.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateJobScheduler-12.js +271 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateProgress-3.js +6 -6
- package/dist/node_modules/bullmq/dist/esm/scripts/updateRepeatableJobMillis-1.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/node_modules/bullmq/dist/esm/types/deduplication-options.d.ts +22 -0
- package/dist/node_modules/bullmq/dist/esm/types/deduplication-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/index.d.ts +3 -0
- package/dist/node_modules/bullmq/dist/esm/types/index.js +3 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-options.d.ts +19 -8
- package/dist/node_modules/bullmq/dist/esm/types/job-progress.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-progress.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/script-queue-context.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/script-queue-context.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/utils.d.ts +25 -5
- package/dist/node_modules/bullmq/dist/esm/utils.js +27 -0
- package/dist/node_modules/bullmq/dist/esm/version.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/version.js +1 -1
- package/dist/node_modules/bullmq/package.json +1 -1
- package/package.json +7 -7
- package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-2.lua +0 -91
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -53
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
- package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-10.lua +0 -60
- package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-9.lua +0 -156
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-5.lua +0 -68
- package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-2.js +0 -237
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-9.js +0 -529
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-5.js +0 -83
- package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-2.lua +0 -91
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -53
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
- package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-10.lua +0 -60
- package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-9.lua +0 -156
- package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-5.lua +0 -68
- package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.d.ts +0 -13
- package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.js +0 -2
- package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-2.js +0 -234
- package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-9.js +0 -526
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-5.js +0 -80
- /package/dist/node_modules/bullmq/dist/esm/scripts/{addJobScheduler-2.d.ts → addJobScheduler-11.d.ts} +0 -0
- /package/dist/node_modules/bullmq/dist/esm/scripts/{addParentJob-4.d.ts → addParentJob-5.d.ts} +0 -0
- /package/dist/node_modules/bullmq/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-9.d.ts} +0 -0
- /package/dist/node_modules/bullmq/dist/esm/scripts/{addStandardJob-8.d.ts → addStandardJob-9.d.ts} +0 -0
- /package/dist/node_modules/bullmq/dist/esm/scripts/{moveJobFromActiveToWait-10.d.ts → moveJobFromActiveToWait-9.d.ts} +0 -0
- /package/dist/node_modules/bullmq/dist/esm/scripts/{moveStalledJobsToWait-9.d.ts → moveStalledJobsToWait-8.d.ts} +0 -0
- /package/dist/node_modules/bullmq/dist/esm/scripts/{moveToWaitingChildren-5.d.ts → moveToWaitingChildren-8.d.ts} +0 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
const content = `--[[
|
|
2
|
+
Adds a job scheduler, i.e. a job factory that creates jobs based on a given schedule (repeat options).
|
|
3
|
+
Input:
|
|
4
|
+
KEYS[1] 'repeat' key
|
|
5
|
+
KEYS[2] 'delayed' key
|
|
6
|
+
KEYS[3] 'wait' key
|
|
7
|
+
KEYS[4] 'paused' key
|
|
8
|
+
KEYS[5] 'meta' key
|
|
9
|
+
KEYS[6] 'prioritized' key
|
|
10
|
+
KEYS[7] 'marker' key
|
|
11
|
+
KEYS[8] 'id' key
|
|
12
|
+
KEYS[9] 'events' key
|
|
13
|
+
KEYS[10] 'pc' priority counter
|
|
14
|
+
KEYS[11] 'active' key
|
|
15
|
+
ARGV[1] next milliseconds
|
|
16
|
+
ARGV[2] msgpacked options
|
|
17
|
+
[1] name
|
|
18
|
+
[2] tz?
|
|
19
|
+
[3] patten?
|
|
20
|
+
[4] endDate?
|
|
21
|
+
[5] every?
|
|
22
|
+
ARGV[3] jobs scheduler id
|
|
23
|
+
ARGV[4] Json stringified template data
|
|
24
|
+
ARGV[5] mspacked template opts
|
|
25
|
+
ARGV[6] msgpacked delayed opts
|
|
26
|
+
ARGV[7] timestamp
|
|
27
|
+
ARGV[8] prefix key
|
|
28
|
+
ARGV[9] producer key
|
|
29
|
+
Output:
|
|
30
|
+
repeatableKey - OK
|
|
31
|
+
]]
|
|
32
|
+
local rcall = redis.call
|
|
33
|
+
local repeatKey = KEYS[1]
|
|
34
|
+
local delayedKey = KEYS[2]
|
|
35
|
+
local waitKey = KEYS[3]
|
|
36
|
+
local pausedKey = KEYS[4]
|
|
37
|
+
local metaKey = KEYS[5]
|
|
38
|
+
local prioritizedKey = KEYS[6]
|
|
39
|
+
local eventsKey = KEYS[9]
|
|
40
|
+
local nextMillis = ARGV[1]
|
|
41
|
+
local jobSchedulerId = ARGV[3]
|
|
42
|
+
local templateOpts = cmsgpack.unpack(ARGV[5])
|
|
43
|
+
local prefixKey = ARGV[8]
|
|
44
|
+
-- Includes
|
|
45
|
+
--[[
|
|
46
|
+
Add delay marker if needed.
|
|
47
|
+
]]
|
|
48
|
+
-- Includes
|
|
49
|
+
--[[
|
|
50
|
+
Adds a delayed job to the queue by doing the following:
|
|
51
|
+
- Creates a new job key with the job data.
|
|
52
|
+
- adds to delayed zset.
|
|
53
|
+
- Emits a global event 'delayed' if the job is delayed.
|
|
54
|
+
]]
|
|
55
|
+
-- Includes
|
|
56
|
+
--[[
|
|
57
|
+
Add delay marker if needed.
|
|
58
|
+
]]
|
|
59
|
+
-- Includes
|
|
60
|
+
--[[
|
|
61
|
+
Function to return the next delayed job timestamp.
|
|
62
|
+
]]
|
|
63
|
+
local function getNextDelayedTimestamp(delayedKey)
|
|
64
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
|
65
|
+
if #result then
|
|
66
|
+
local nextTimestamp = tonumber(result[2])
|
|
67
|
+
if nextTimestamp ~= nil then
|
|
68
|
+
return nextTimestamp / 0x1000
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
73
|
+
local nextTimestamp = getNextDelayedTimestamp(delayedKey)
|
|
74
|
+
if nextTimestamp ~= nil then
|
|
75
|
+
-- Replace the score of the marker with the newest known
|
|
76
|
+
-- next timestamp.
|
|
77
|
+
rcall("ZADD", markerKey, nextTimestamp, "1")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
--[[
|
|
81
|
+
Bake in the job id first 12 bits into the timestamp
|
|
82
|
+
to guarantee correct execution order of delayed jobs
|
|
83
|
+
(up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)
|
|
84
|
+
WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail
|
|
85
|
+
]]
|
|
86
|
+
local function getDelayedScore(delayedKey, timestamp, delay)
|
|
87
|
+
local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)
|
|
88
|
+
local minScore = delayedTimestamp * 0x1000
|
|
89
|
+
local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1
|
|
90
|
+
local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,
|
|
91
|
+
minScore, "WITHSCORES","LIMIT", 0, 1)
|
|
92
|
+
if #result then
|
|
93
|
+
local currentMaxScore = tonumber(result[2])
|
|
94
|
+
if currentMaxScore ~= nil then
|
|
95
|
+
if currentMaxScore >= maxScore then
|
|
96
|
+
return maxScore, delayedTimestamp
|
|
97
|
+
else
|
|
98
|
+
return currentMaxScore + 1, delayedTimestamp
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
return minScore, delayedTimestamp
|
|
103
|
+
end
|
|
104
|
+
local function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,
|
|
105
|
+
maxEvents, markerKey, delay)
|
|
106
|
+
local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))
|
|
107
|
+
rcall("ZADD", delayedKey, score, jobId)
|
|
108
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
|
109
|
+
"jobId", jobId, "delay", delayedTimestamp)
|
|
110
|
+
-- mark that a delayed job is available
|
|
111
|
+
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
112
|
+
end
|
|
113
|
+
--[[
|
|
114
|
+
Function to add job considering priority.
|
|
115
|
+
]]
|
|
116
|
+
-- Includes
|
|
117
|
+
--[[
|
|
118
|
+
Add marker if needed when a job is available.
|
|
119
|
+
]]
|
|
120
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
|
121
|
+
if not isPausedOrMaxed then
|
|
122
|
+
rcall("ZADD", markerKey, 0, "0")
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
--[[
|
|
126
|
+
Function to get priority score.
|
|
127
|
+
]]
|
|
128
|
+
local function getPriorityScore(priority, priorityCounterKey)
|
|
129
|
+
local prioCounter = rcall("INCR", priorityCounterKey)
|
|
130
|
+
return priority * 0x100000000 + prioCounter % 0x100000000
|
|
131
|
+
end
|
|
132
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
|
133
|
+
isPausedOrMaxed)
|
|
134
|
+
local score = getPriorityScore(priority, priorityCounterKey)
|
|
135
|
+
rcall("ZADD", prioritizedKey, score, jobId)
|
|
136
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
|
137
|
+
end
|
|
138
|
+
--[[
|
|
139
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
|
140
|
+
(since an empty list and !EXISTS are not really the same).
|
|
141
|
+
]]
|
|
142
|
+
local function isQueuePaused(queueMetaKey)
|
|
143
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
|
144
|
+
end
|
|
145
|
+
--[[
|
|
146
|
+
Function to store a job
|
|
147
|
+
]]
|
|
148
|
+
local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
149
|
+
parentKey, parentData, repeatJobKey)
|
|
150
|
+
local jsonOpts = cjson.encode(opts)
|
|
151
|
+
local delay = opts['delay'] or 0
|
|
152
|
+
local priority = opts['priority'] or 0
|
|
153
|
+
local debounceId = opts['de'] and opts['de']['id']
|
|
154
|
+
local optionalValues = {}
|
|
155
|
+
if parentKey ~= nil then
|
|
156
|
+
table.insert(optionalValues, "parentKey")
|
|
157
|
+
table.insert(optionalValues, parentKey)
|
|
158
|
+
table.insert(optionalValues, "parent")
|
|
159
|
+
table.insert(optionalValues, parentData)
|
|
160
|
+
end
|
|
161
|
+
if repeatJobKey then
|
|
162
|
+
table.insert(optionalValues, "rjk")
|
|
163
|
+
table.insert(optionalValues, repeatJobKey)
|
|
164
|
+
end
|
|
165
|
+
if debounceId then
|
|
166
|
+
table.insert(optionalValues, "deid")
|
|
167
|
+
table.insert(optionalValues, debounceId)
|
|
168
|
+
end
|
|
169
|
+
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
|
170
|
+
"timestamp", timestamp, "delay", delay, "priority", priority,
|
|
171
|
+
unpack(optionalValues))
|
|
172
|
+
rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)
|
|
173
|
+
return delay, priority
|
|
174
|
+
end
|
|
175
|
+
--[[
|
|
176
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
|
177
|
+
(since an empty list and !EXISTS are not really the same).
|
|
178
|
+
]]
|
|
179
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
180
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
181
|
+
if queueAttributes[1] then
|
|
182
|
+
return pausedKey, true
|
|
183
|
+
else
|
|
184
|
+
if queueAttributes[2] then
|
|
185
|
+
local activeCount = rcall("LLEN", activeKey)
|
|
186
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
|
187
|
+
return waitKey, true
|
|
188
|
+
else
|
|
189
|
+
return waitKey, false
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
return waitKey, false
|
|
194
|
+
end
|
|
195
|
+
--[[
|
|
196
|
+
Function to add job in target list and add marker if needed.
|
|
197
|
+
]]
|
|
198
|
+
-- Includes
|
|
199
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
|
200
|
+
rcall(pushCmd, targetKey, jobId)
|
|
201
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
|
202
|
+
end
|
|
203
|
+
local function addJobFromScheduler(jobKey, jobId, rawOpts, waitKey, pausedKey, activeKey, metaKey,
|
|
204
|
+
prioritizedKey, priorityCounter, delayedKey, markerKey, eventsKey, name, maxEvents, timestamp,
|
|
205
|
+
data, jobSchedulerId)
|
|
206
|
+
local opts = cmsgpack.unpack(rawOpts)
|
|
207
|
+
local delay, priority = storeJob(eventsKey, jobKey, jobId, name, data,
|
|
208
|
+
opts, timestamp, nil, nil, jobSchedulerId)
|
|
209
|
+
if delay ~= 0 then
|
|
210
|
+
addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, markerKey, delay)
|
|
211
|
+
else
|
|
212
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)
|
|
213
|
+
-- Standard or priority add
|
|
214
|
+
if priority == 0 then
|
|
215
|
+
local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'
|
|
216
|
+
addJobInTargetList(target, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
|
217
|
+
else
|
|
218
|
+
-- Priority add
|
|
219
|
+
addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounter, isPausedOrMaxed)
|
|
220
|
+
end
|
|
221
|
+
-- Emit waiting event
|
|
222
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", jobId)
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
--[[
|
|
226
|
+
Function to get max events value or set by default 10000.
|
|
227
|
+
]]
|
|
228
|
+
local function getOrSetMaxEvents(metaKey)
|
|
229
|
+
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
|
|
230
|
+
if not maxEvents then
|
|
231
|
+
maxEvents = 10000
|
|
232
|
+
rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
|
|
233
|
+
end
|
|
234
|
+
return maxEvents
|
|
235
|
+
end
|
|
236
|
+
--[[
|
|
237
|
+
Function to remove job.
|
|
238
|
+
]]
|
|
239
|
+
-- Includes
|
|
240
|
+
--[[
|
|
241
|
+
Function to remove deduplication key if needed
|
|
242
|
+
when a job is being removed.
|
|
243
|
+
]]
|
|
244
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
|
245
|
+
jobKey, jobId)
|
|
246
|
+
local deduplicationId = rcall("HGET", jobKey, "deid")
|
|
247
|
+
if deduplicationId then
|
|
248
|
+
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
|
249
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
|
250
|
+
if currentJobId and currentJobId == jobId then
|
|
251
|
+
return rcall("DEL", deduplicationKey)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
--[[
|
|
256
|
+
Function to remove job keys.
|
|
257
|
+
]]
|
|
258
|
+
local function removeJobKeys(jobKey)
|
|
259
|
+
return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
|
|
260
|
+
jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
|
|
261
|
+
end
|
|
262
|
+
--[[
|
|
263
|
+
Check if this job has a parent. If so we will just remove it from
|
|
264
|
+
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
|
265
|
+
which requires code from "moveToFinished"
|
|
266
|
+
]]
|
|
267
|
+
-- Includes
|
|
268
|
+
--[[
|
|
269
|
+
Functions to destructure job key.
|
|
270
|
+
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
|
271
|
+
]]
|
|
272
|
+
local getJobIdFromKey = function (jobKey)
|
|
273
|
+
return string.match(jobKey, ".*:(.*)")
|
|
274
|
+
end
|
|
275
|
+
local getJobKeyPrefix = function (jobKey, jobId)
|
|
276
|
+
return string.sub(jobKey, 0, #jobKey - #jobId)
|
|
277
|
+
end
|
|
278
|
+
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
279
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
280
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
|
281
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
|
282
|
+
if emitEvent then
|
|
283
|
+
local parentEventStream = parentPrefix .. "events"
|
|
284
|
+
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
|
288
|
+
if parentKey then
|
|
289
|
+
local parentDependenciesKey = parentKey .. ":dependencies"
|
|
290
|
+
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
|
291
|
+
if result > 0 then
|
|
292
|
+
local pendingDependencies = rcall("SCARD", parentDependenciesKey)
|
|
293
|
+
if pendingDependencies == 0 then
|
|
294
|
+
local parentId = getJobIdFromKey(parentKey)
|
|
295
|
+
local parentPrefix = getJobKeyPrefix(parentKey, parentId)
|
|
296
|
+
local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
|
|
297
|
+
if numRemovedElements == 1 then
|
|
298
|
+
if hard then -- remove parent in same queue
|
|
299
|
+
if parentPrefix == baseKey then
|
|
300
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
|
301
|
+
removeJobKeys(parentKey)
|
|
302
|
+
if debounceId then
|
|
303
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
|
304
|
+
end
|
|
305
|
+
else
|
|
306
|
+
_moveParentToWait(parentPrefix, parentId)
|
|
307
|
+
end
|
|
308
|
+
else
|
|
309
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
return true
|
|
314
|
+
end
|
|
315
|
+
else
|
|
316
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
|
317
|
+
local missedParentKey = parentAttributes[1]
|
|
318
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
|
319
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
|
320
|
+
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
|
321
|
+
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
|
322
|
+
if result > 0 then
|
|
323
|
+
local pendingDependencies = rcall("SCARD", parentDependenciesKey)
|
|
324
|
+
if pendingDependencies == 0 then
|
|
325
|
+
local parentId = getJobIdFromKey(missedParentKey)
|
|
326
|
+
local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
|
|
327
|
+
local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
|
|
328
|
+
if numRemovedElements == 1 then
|
|
329
|
+
if hard then
|
|
330
|
+
if parentPrefix == baseKey then
|
|
331
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
|
332
|
+
removeJobKeys(missedParentKey)
|
|
333
|
+
if parentAttributes[2] then
|
|
334
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
|
335
|
+
end
|
|
336
|
+
else
|
|
337
|
+
_moveParentToWait(parentPrefix, parentId)
|
|
338
|
+
end
|
|
339
|
+
else
|
|
340
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
end
|
|
344
|
+
return true
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
return false
|
|
349
|
+
end
|
|
350
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
351
|
+
local jobKey = baseKey .. jobId
|
|
352
|
+
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
|
353
|
+
if shouldRemoveDeduplicationKey then
|
|
354
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
|
355
|
+
end
|
|
356
|
+
removeJobKeys(jobKey)
|
|
357
|
+
end
|
|
358
|
+
--[[
|
|
359
|
+
Function to store a job scheduler
|
|
360
|
+
]]
|
|
361
|
+
local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMillis, opts,
|
|
362
|
+
templateData, templateOpts)
|
|
363
|
+
rcall("ZADD", repeatKey, nextMillis, schedulerId)
|
|
364
|
+
local optionalValues = {}
|
|
365
|
+
if opts['tz'] then
|
|
366
|
+
table.insert(optionalValues, "tz")
|
|
367
|
+
table.insert(optionalValues, opts['tz'])
|
|
368
|
+
end
|
|
369
|
+
if opts['limit'] then
|
|
370
|
+
table.insert(optionalValues, "limit")
|
|
371
|
+
table.insert(optionalValues, opts['limit'])
|
|
372
|
+
end
|
|
373
|
+
if opts['pattern'] then
|
|
374
|
+
table.insert(optionalValues, "pattern")
|
|
375
|
+
table.insert(optionalValues, opts['pattern'])
|
|
376
|
+
end
|
|
377
|
+
if opts['endDate'] then
|
|
378
|
+
table.insert(optionalValues, "endDate")
|
|
379
|
+
table.insert(optionalValues, opts['endDate'])
|
|
380
|
+
end
|
|
381
|
+
if opts['every'] then
|
|
382
|
+
table.insert(optionalValues, "every")
|
|
383
|
+
table.insert(optionalValues, opts['every'])
|
|
384
|
+
end
|
|
385
|
+
if opts['offset'] then
|
|
386
|
+
table.insert(optionalValues, "offset")
|
|
387
|
+
table.insert(optionalValues, opts['offset'])
|
|
388
|
+
end
|
|
389
|
+
local jsonTemplateOpts = cjson.encode(templateOpts)
|
|
390
|
+
if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then
|
|
391
|
+
table.insert(optionalValues, "opts")
|
|
392
|
+
table.insert(optionalValues, jsonTemplateOpts)
|
|
393
|
+
end
|
|
394
|
+
if templateData and templateData ~= '{}' then
|
|
395
|
+
table.insert(optionalValues, "data")
|
|
396
|
+
table.insert(optionalValues, templateData)
|
|
397
|
+
end
|
|
398
|
+
rcall("DEL", schedulerKey) -- remove all attributes and then re-insert new ones
|
|
399
|
+
rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))
|
|
400
|
+
end
|
|
401
|
+
-- If we are overriding a repeatable job we must delete the delayed job for
|
|
402
|
+
-- the next iteration.
|
|
403
|
+
local schedulerKey = repeatKey .. ":" .. jobSchedulerId
|
|
404
|
+
local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
|
405
|
+
local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
|
|
406
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
|
407
|
+
local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,
|
|
408
|
+
metaKey, eventsKey)
|
|
409
|
+
if rcall("ZSCORE", delayedKey, jobId) then
|
|
410
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
|
411
|
+
rcall("ZREM", delayedKey, jobId)
|
|
412
|
+
return true
|
|
413
|
+
elseif rcall("ZSCORE", prioritizedKey, jobId) then
|
|
414
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
|
415
|
+
rcall("ZREM", prioritizedKey, jobId)
|
|
416
|
+
return true
|
|
417
|
+
else
|
|
418
|
+
local pausedOrWaitKey = waitKey
|
|
419
|
+
if isQueuePaused(metaKey) then
|
|
420
|
+
pausedOrWaitKey = pausedKey
|
|
421
|
+
end
|
|
422
|
+
if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then
|
|
423
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
|
424
|
+
return true
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
return false
|
|
428
|
+
end
|
|
429
|
+
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
|
430
|
+
if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
|
431
|
+
nextDelayedJobId, metaKey, eventsKey) then
|
|
432
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
|
433
|
+
"duplicated", "jobId", nextDelayedJobId)
|
|
434
|
+
return nextDelayedJobId .. "" -- convert to string
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
|
438
|
+
if prevMillis then
|
|
439
|
+
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
|
440
|
+
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
|
441
|
+
if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
|
|
442
|
+
removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
|
443
|
+
currentJobId, metaKey, eventsKey)
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
local schedulerOpts = cmsgpack.unpack(ARGV[2])
|
|
447
|
+
storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
|
|
448
|
+
rcall("INCR", KEYS[8])
|
|
449
|
+
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
|
|
450
|
+
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
|
451
|
+
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
|
452
|
+
if ARGV[9] ~= "" then
|
|
453
|
+
rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
|
|
454
|
+
end
|
|
455
|
+
return nextDelayedJobId .. "" -- convert to string
|
|
456
|
+
`;
|
|
457
|
+
export const addJobScheduler = {
|
|
458
|
+
name: 'addJobScheduler',
|
|
459
|
+
content,
|
|
460
|
+
keys: 11,
|
|
461
|
+
};
|
|
462
|
+
//# sourceMappingURL=addJobScheduler-11.js.map
|