@tachybase/plugin-print-template 1.3.16 → 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 +4 -4
- package/dist/index.js +4 -4
- 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/dist/node_modules/docxtemplater/package.json +1 -1
- package/dist/node_modules/pizzip/package.json +1 -1
- package/package.json +8 -8
- 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
|
@@ -11,7 +11,6 @@ const utils_1 = require("../utils");
|
|
|
11
11
|
const queue_base_1 = require("./queue-base");
|
|
12
12
|
const repeat_1 = require("./repeat");
|
|
13
13
|
const child_pool_1 = require("./child-pool");
|
|
14
|
-
const job_1 = require("./job");
|
|
15
14
|
const redis_connection_1 = require("./redis-connection");
|
|
16
15
|
const sandbox_1 = require("./sandbox");
|
|
17
16
|
const async_fifo_queue_1 = require("./async-fifo-queue");
|
|
@@ -21,7 +20,7 @@ const job_scheduler_1 = require("./job-scheduler");
|
|
|
21
20
|
// 10 seconds is the maximum time a BZPOPMIN can block.
|
|
22
21
|
const maximumBlockTimeout = 10;
|
|
23
22
|
// 30 seconds is the maximum limit until.
|
|
24
|
-
const
|
|
23
|
+
const maximumRateLimitDelay = 30000;
|
|
25
24
|
/**
|
|
26
25
|
*
|
|
27
26
|
* This class represents a worker that is able to process jobs from the queue.
|
|
@@ -34,7 +33,7 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
34
33
|
return new errors_1.RateLimitError();
|
|
35
34
|
}
|
|
36
35
|
constructor(name, processor, opts, Connection) {
|
|
37
|
-
super(name, Object.assign(Object.assign({}, opts), { blockingConnection: true }), Connection);
|
|
36
|
+
super(name, Object.assign(Object.assign({ drainDelay: 5, concurrency: 1, lockDuration: 30000, maxStalledCount: 1, stalledInterval: 30000, autorun: true, runRetryDelay: 15000 }, opts), { blockingConnection: true }), Connection);
|
|
38
37
|
this.abortDelayController = null;
|
|
39
38
|
this.blockUntil = 0;
|
|
40
39
|
this.drained = false;
|
|
@@ -42,14 +41,19 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
42
41
|
this.limitUntil = 0;
|
|
43
42
|
this.waiting = null;
|
|
44
43
|
this.running = false;
|
|
44
|
+
this.mainLoopRunning = null;
|
|
45
45
|
if (!opts || !opts.connection) {
|
|
46
46
|
throw new Error('Worker requires a connection');
|
|
47
47
|
}
|
|
48
|
-
this.opts
|
|
49
|
-
|
|
48
|
+
if (typeof this.opts.maxStalledCount !== 'number' ||
|
|
49
|
+
this.opts.maxStalledCount < 0) {
|
|
50
|
+
throw new Error('maxStalledCount must be greater or equal than 0');
|
|
51
|
+
}
|
|
52
|
+
if (typeof this.opts.stalledInterval !== 'number' ||
|
|
53
|
+
this.opts.stalledInterval <= 0) {
|
|
50
54
|
throw new Error('stalledInterval must be greater than 0');
|
|
51
55
|
}
|
|
52
|
-
if (this.opts.drainDelay <= 0) {
|
|
56
|
+
if (typeof this.opts.drainDelay !== 'number' || this.opts.drainDelay <= 0) {
|
|
53
57
|
throw new Error('drainDelay must be greater than 0');
|
|
54
58
|
}
|
|
55
59
|
this.concurrency = this.opts.concurrency;
|
|
@@ -108,7 +112,11 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
108
112
|
const connectionName = this.clientName() + (this.opts.name ? `:w:${this.opts.name}` : '');
|
|
109
113
|
this.blockingConnection = new redis_connection_1.RedisConnection((0, utils_1.isRedisInstance)(opts.connection)
|
|
110
114
|
? opts.connection.duplicate({ connectionName })
|
|
111
|
-
: Object.assign(Object.assign({}, opts.connection), { connectionName }),
|
|
115
|
+
: Object.assign(Object.assign({}, opts.connection), { connectionName }), {
|
|
116
|
+
shared: false,
|
|
117
|
+
blocking: true,
|
|
118
|
+
skipVersionCheck: opts.skipVersionCheck,
|
|
119
|
+
});
|
|
112
120
|
this.blockingConnection.on('error', error => this.emit('error', error));
|
|
113
121
|
this.blockingConnection.on('ready', () => setTimeout(() => this.emit('ready'), 0));
|
|
114
122
|
}
|
|
@@ -183,70 +191,87 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
183
191
|
}
|
|
184
192
|
try {
|
|
185
193
|
this.running = true;
|
|
186
|
-
if (this.closing) {
|
|
194
|
+
if (this.closing || this.paused) {
|
|
187
195
|
return;
|
|
188
196
|
}
|
|
189
197
|
await this.startStalledCheckTimer();
|
|
190
|
-
const jobsInProgress = new Set();
|
|
191
|
-
this.startLockExtenderTimer(jobsInProgress);
|
|
192
|
-
const asyncFifoQueue = (this.asyncFifoQueue =
|
|
193
|
-
new async_fifo_queue_1.AsyncFifoQueue());
|
|
194
|
-
let tokenPostfix = 0;
|
|
195
198
|
const client = await this.client;
|
|
196
199
|
const bclient = await this.blockingConnection.client;
|
|
200
|
+
this.mainLoopRunning = this.mainLoop(client, bclient);
|
|
201
|
+
// We must await here or finally will be called too early.
|
|
202
|
+
await this.mainLoopRunning;
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
this.running = false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async waitForRateLimit() {
|
|
209
|
+
var _a;
|
|
210
|
+
const limitUntil = this.limitUntil;
|
|
211
|
+
if (limitUntil > Date.now()) {
|
|
212
|
+
(_a = this.abortDelayController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
213
|
+
this.abortDelayController = new node_abort_controller_1.AbortController();
|
|
214
|
+
const delay = this.getRateLimitDelay(limitUntil - Date.now());
|
|
215
|
+
await this.delay(delay, this.abortDelayController);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* This is the main loop in BullMQ. Its goals are to fetch jobs from the queue
|
|
220
|
+
* as efficiently as possible, providing concurrency and minimal unnecessary calls
|
|
221
|
+
* to Redis.
|
|
222
|
+
*/
|
|
223
|
+
async mainLoop(client, bclient) {
|
|
224
|
+
const asyncFifoQueue = new async_fifo_queue_1.AsyncFifoQueue();
|
|
225
|
+
const jobsInProgress = new Set();
|
|
226
|
+
this.startLockExtenderTimer(jobsInProgress);
|
|
227
|
+
let tokenPostfix = 0;
|
|
228
|
+
while (!this.closing && !this.paused) {
|
|
229
|
+
let numTotal = asyncFifoQueue.numTotal();
|
|
197
230
|
/**
|
|
198
|
-
* This
|
|
199
|
-
*
|
|
200
|
-
* to Redis.
|
|
231
|
+
* This inner loop tries to fetch jobs concurrently, but if we are waiting for a job
|
|
232
|
+
* to arrive at the queue we should not try to fetch more jobs (as it would be pointless)
|
|
201
233
|
*/
|
|
202
|
-
while (!this.closing
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const job = await fetchedJob;
|
|
222
|
-
// No more jobs waiting but we have others that could start processing already
|
|
223
|
-
if (!job && numTotal > 1) {
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
// If there are potential jobs to be processed and blockUntil is set, we should exit to avoid waiting
|
|
227
|
-
// for processing this job.
|
|
228
|
-
if (this.blockUntil) {
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
234
|
+
while (!this.closing &&
|
|
235
|
+
!this.paused &&
|
|
236
|
+
!this.waiting &&
|
|
237
|
+
numTotal < this._concurrency &&
|
|
238
|
+
!this.isRateLimited()) {
|
|
239
|
+
const token = `${this.id}:${tokenPostfix++}`;
|
|
240
|
+
const fetchedJob = this.retryIfFailed(() => this._getNextJob(client, bclient, token, { block: true }), this.opts.runRetryDelay);
|
|
241
|
+
asyncFifoQueue.add(fetchedJob);
|
|
242
|
+
numTotal = asyncFifoQueue.numTotal();
|
|
243
|
+
if (this.waiting && numTotal > 1) {
|
|
244
|
+
// We are waiting for jobs but we have others that we could start processing already
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
// We await here so that we fetch jobs in sequence, this is important to avoid unnecessary calls
|
|
248
|
+
// to Redis in high concurrency scenarios.
|
|
249
|
+
const job = await fetchedJob;
|
|
250
|
+
// No more jobs waiting but we have others that could start processing already
|
|
251
|
+
if (!job && numTotal > 1) {
|
|
252
|
+
break;
|
|
231
253
|
}
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
job = await asyncFifoQueue.fetch();
|
|
237
|
-
} while (!job && asyncFifoQueue.numQueued() > 0);
|
|
238
|
-
if (job) {
|
|
239
|
-
const token = job.token;
|
|
240
|
-
asyncFifoQueue.add(this.retryIfFailed(() => this.processJob(job, token, () => asyncFifoQueue.numTotal() <= this._concurrency, jobsInProgress), this.opts.runRetryDelay));
|
|
254
|
+
// If there are potential jobs to be processed and blockUntil is set, we should exit to avoid waiting
|
|
255
|
+
// for processing this job.
|
|
256
|
+
if (this.blockUntil) {
|
|
257
|
+
break;
|
|
241
258
|
}
|
|
242
259
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
260
|
+
// Since there can be undefined jobs in the queue (when a job fails or queue is empty)
|
|
261
|
+
// we iterate until we find a job.
|
|
262
|
+
let job;
|
|
263
|
+
do {
|
|
264
|
+
job = await asyncFifoQueue.fetch();
|
|
265
|
+
} while (!job && asyncFifoQueue.numQueued() > 0);
|
|
266
|
+
if (job) {
|
|
267
|
+
const token = job.token;
|
|
268
|
+
asyncFifoQueue.add(this.retryIfFailed(() => this.processJob(job, token, () => asyncFifoQueue.numTotal() <= this._concurrency, jobsInProgress), this.opts.runRetryDelay));
|
|
269
|
+
}
|
|
270
|
+
else if (asyncFifoQueue.numQueued() === 0) {
|
|
271
|
+
await this.waitForRateLimit();
|
|
272
|
+
}
|
|
249
273
|
}
|
|
274
|
+
return asyncFifoQueue.waitAll();
|
|
250
275
|
}
|
|
251
276
|
/**
|
|
252
277
|
* Returns a promise that resolves to the next job in queue.
|
|
@@ -268,14 +293,8 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
268
293
|
}, (_b = (_a = nextJob === null || nextJob === void 0 ? void 0 : nextJob.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.metadata);
|
|
269
294
|
}
|
|
270
295
|
async _getNextJob(client, bclient, token, { block = true } = {}) {
|
|
271
|
-
var _a;
|
|
272
296
|
if (this.paused) {
|
|
273
|
-
|
|
274
|
-
await this.paused;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
297
|
+
return;
|
|
279
298
|
}
|
|
280
299
|
if (this.closing) {
|
|
281
300
|
return;
|
|
@@ -300,13 +319,9 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
300
319
|
}
|
|
301
320
|
}
|
|
302
321
|
else {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
(_a = this.abortDelayController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
306
|
-
this.abortDelayController = new node_abort_controller_1.AbortController();
|
|
307
|
-
await this.delay(this.getLimitUntil(limitUntil), this.abortDelayController);
|
|
322
|
+
if (!this.isRateLimited()) {
|
|
323
|
+
return this.moveToActive(client, token, this.opts.name);
|
|
308
324
|
}
|
|
309
|
-
return this.moveToActive(client, token, this.opts.name);
|
|
310
325
|
}
|
|
311
326
|
}
|
|
312
327
|
/**
|
|
@@ -331,9 +346,12 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
331
346
|
0.001
|
|
332
347
|
: 0.002;
|
|
333
348
|
}
|
|
349
|
+
isRateLimited() {
|
|
350
|
+
return this.limitUntil > Date.now();
|
|
351
|
+
}
|
|
334
352
|
async moveToActive(client, token, name) {
|
|
335
|
-
const [jobData, id,
|
|
336
|
-
this.updateDelays(
|
|
353
|
+
const [jobData, id, rateLimitDelay, delayUntil] = await this.scripts.moveToActive(client, token, name);
|
|
354
|
+
this.updateDelays(rateLimitDelay, delayUntil);
|
|
337
355
|
return this.nextJobFromJobData(jobData, id, token);
|
|
338
356
|
}
|
|
339
357
|
async waitForJob(bclient, blockUntil) {
|
|
@@ -342,7 +360,7 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
342
360
|
}
|
|
343
361
|
let timeout;
|
|
344
362
|
try {
|
|
345
|
-
if (!this.closing && !this.
|
|
363
|
+
if (!this.closing && !this.isRateLimited()) {
|
|
346
364
|
let blockTimeout = this.getBlockTimeout(blockUntil);
|
|
347
365
|
if (blockTimeout > 0) {
|
|
348
366
|
blockTimeout = this.blockingConnection.capabilities.canDoubleTimeout
|
|
@@ -361,7 +379,13 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
361
379
|
if (result) {
|
|
362
380
|
const [_key, member, score] = result;
|
|
363
381
|
if (member) {
|
|
364
|
-
|
|
382
|
+
const newBlockUntil = parseInt(score);
|
|
383
|
+
// Use by pro version as rate limited groups could generate lower blockUntil values
|
|
384
|
+
// markers only return delays for delayed jobs
|
|
385
|
+
if (blockUntil && newBlockUntil > blockUntil) {
|
|
386
|
+
return blockUntil;
|
|
387
|
+
}
|
|
388
|
+
return newBlockUntil;
|
|
365
389
|
}
|
|
366
390
|
}
|
|
367
391
|
}
|
|
@@ -404,10 +428,10 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
404
428
|
return Math.max(opts.drainDelay, this.minimumBlockTimeout);
|
|
405
429
|
}
|
|
406
430
|
}
|
|
407
|
-
|
|
431
|
+
getRateLimitDelay(delay) {
|
|
408
432
|
// We restrict the maximum limit until to 30 second to
|
|
409
433
|
// be able to promote delayed jobs while queue is rate limited
|
|
410
|
-
return Math.min(
|
|
434
|
+
return Math.min(delay, maximumRateLimitDelay);
|
|
411
435
|
}
|
|
412
436
|
/**
|
|
413
437
|
*
|
|
@@ -416,8 +440,14 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
416
440
|
async delay(milliseconds, abortController) {
|
|
417
441
|
await (0, utils_1.delay)(milliseconds || utils_1.DELAY_TIME_1, abortController);
|
|
418
442
|
}
|
|
419
|
-
updateDelays(
|
|
420
|
-
|
|
443
|
+
updateDelays(limitDelay = 0, delayUntil = 0) {
|
|
444
|
+
const clampedLimit = Math.max(limitDelay, 0);
|
|
445
|
+
if (clampedLimit > 0) {
|
|
446
|
+
this.limitUntil = Date.now() + clampedLimit;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
this.limitUntil = 0;
|
|
450
|
+
}
|
|
421
451
|
this.blockUntil = Math.max(delayUntil, 0) || 0;
|
|
422
452
|
}
|
|
423
453
|
async nextJobFromJobData(jobData, jobId, token) {
|
|
@@ -450,9 +480,6 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
450
480
|
}
|
|
451
481
|
async processJob(job, token, fetchNextCallback = () => true, jobsInProgress) {
|
|
452
482
|
var _a, _b;
|
|
453
|
-
if (!job || this.closing || this.paused) {
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
483
|
const srcPropagationMedatada = (_b = (_a = job.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.metadata;
|
|
457
484
|
return this.trace(enums_1.SpanKind.CONSUMER, 'process', this.name, async (span) => {
|
|
458
485
|
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
@@ -460,64 +487,20 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
460
487
|
[enums_1.TelemetryAttributes.WorkerName]: this.opts.name,
|
|
461
488
|
[enums_1.TelemetryAttributes.JobId]: job.id,
|
|
462
489
|
});
|
|
463
|
-
const handleCompleted = async (result) => {
|
|
464
|
-
jobsInProgress.delete(inProgressItem);
|
|
465
|
-
if (!this.connection.closing) {
|
|
466
|
-
const completed = await job.moveToCompleted(result, token, fetchNextCallback() && !(this.closing || this.paused));
|
|
467
|
-
this.emit('completed', job, result, 'active');
|
|
468
|
-
span === null || span === void 0 ? void 0 : span.addEvent('job completed', {
|
|
469
|
-
[enums_1.TelemetryAttributes.JobResult]: JSON.stringify(result),
|
|
470
|
-
});
|
|
471
|
-
const [jobData, jobId, limitUntil, delayUntil] = completed || [];
|
|
472
|
-
this.updateDelays(limitUntil, delayUntil);
|
|
473
|
-
return this.nextJobFromJobData(jobData, jobId, token);
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
const handleFailed = async (err) => {
|
|
477
|
-
jobsInProgress.delete(inProgressItem);
|
|
478
|
-
if (!this.connection.closing) {
|
|
479
|
-
try {
|
|
480
|
-
// Check if the job was manually rate-limited
|
|
481
|
-
if (err.message == errors_1.RATE_LIMIT_ERROR) {
|
|
482
|
-
this.limitUntil = await this.moveLimitedBackToWait(job, token);
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
if (err instanceof errors_1.DelayedError ||
|
|
486
|
-
err.name == 'DelayedError' ||
|
|
487
|
-
err instanceof errors_1.WaitingChildrenError ||
|
|
488
|
-
err.name == 'WaitingChildrenError') {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
const result = await job.moveToFailed(err, token, true);
|
|
492
|
-
this.emit('failed', job, err, 'active');
|
|
493
|
-
span === null || span === void 0 ? void 0 : span.addEvent('job failed', {
|
|
494
|
-
[enums_1.TelemetryAttributes.JobFailedReason]: err.message,
|
|
495
|
-
});
|
|
496
|
-
if (result) {
|
|
497
|
-
const [jobData, jobId, limitUntil, delayUntil] = result;
|
|
498
|
-
this.updateDelays(limitUntil, delayUntil);
|
|
499
|
-
return this.nextJobFromJobData(jobData, jobId, token);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
catch (err) {
|
|
503
|
-
this.emit('error', err);
|
|
504
|
-
// It probably means that the job has lost the lock before completion
|
|
505
|
-
// A worker will (or already has) moved the job back
|
|
506
|
-
// to the waiting list (as stalled)
|
|
507
|
-
span === null || span === void 0 ? void 0 : span.recordException(err.message);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
490
|
this.emit('active', job, 'waiting');
|
|
512
491
|
const processedOn = Date.now();
|
|
513
492
|
const inProgressItem = { job, ts: processedOn };
|
|
514
493
|
try {
|
|
494
|
+
if (job.deferredFailure) {
|
|
495
|
+
const failed = await this.handleFailed(new errors_1.UnrecoverableError(job.deferredFailure), job, token, fetchNextCallback, jobsInProgress, inProgressItem, span);
|
|
496
|
+
return failed;
|
|
497
|
+
}
|
|
515
498
|
jobsInProgress.add(inProgressItem);
|
|
516
499
|
const result = await this.callProcessJob(job, token);
|
|
517
|
-
return await handleCompleted(result);
|
|
500
|
+
return await this.handleCompleted(result, job, token, fetchNextCallback, jobsInProgress, inProgressItem, span);
|
|
518
501
|
}
|
|
519
502
|
catch (err) {
|
|
520
|
-
const failed = await handleFailed(err);
|
|
503
|
+
const failed = await this.handleFailed(err, job, token, fetchNextCallback, jobsInProgress, inProgressItem, span);
|
|
521
504
|
return failed;
|
|
522
505
|
}
|
|
523
506
|
finally {
|
|
@@ -528,26 +511,73 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
528
511
|
}
|
|
529
512
|
}, srcPropagationMedatada);
|
|
530
513
|
}
|
|
514
|
+
async handleCompleted(result, job, token, fetchNextCallback = () => true, jobsInProgress, inProgressItem, span) {
|
|
515
|
+
jobsInProgress.delete(inProgressItem);
|
|
516
|
+
if (!this.connection.closing) {
|
|
517
|
+
const completed = await job.moveToCompleted(result, token, fetchNextCallback() && !(this.closing || this.paused));
|
|
518
|
+
this.emit('completed', job, result, 'active');
|
|
519
|
+
span === null || span === void 0 ? void 0 : span.addEvent('job completed', {
|
|
520
|
+
[enums_1.TelemetryAttributes.JobResult]: JSON.stringify(result),
|
|
521
|
+
});
|
|
522
|
+
const [jobData, jobId, rateLimitDelay, delayUntil] = completed || [];
|
|
523
|
+
this.updateDelays(rateLimitDelay, delayUntil);
|
|
524
|
+
return this.nextJobFromJobData(jobData, jobId, token);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
async handleFailed(err, job, token, fetchNextCallback = () => true, jobsInProgress, inProgressItem, span) {
|
|
528
|
+
jobsInProgress.delete(inProgressItem);
|
|
529
|
+
if (!this.connection.closing) {
|
|
530
|
+
try {
|
|
531
|
+
// Check if the job was manually rate-limited
|
|
532
|
+
if (err.message == errors_1.RATE_LIMIT_ERROR) {
|
|
533
|
+
const rateLimitTtl = await this.moveLimitedBackToWait(job, token);
|
|
534
|
+
this.limitUntil = rateLimitTtl > 0 ? Date.now() + rateLimitTtl : 0;
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (err instanceof errors_1.DelayedError ||
|
|
538
|
+
err.name == 'DelayedError' ||
|
|
539
|
+
err instanceof errors_1.WaitingError ||
|
|
540
|
+
err.name == 'WaitingError' ||
|
|
541
|
+
err instanceof errors_1.WaitingChildrenError ||
|
|
542
|
+
err.name == 'WaitingChildrenError') {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const result = await job.moveToFailed(err, token, fetchNextCallback() && !(this.closing || this.paused));
|
|
546
|
+
this.emit('failed', job, err, 'active');
|
|
547
|
+
span === null || span === void 0 ? void 0 : span.addEvent('job failed', {
|
|
548
|
+
[enums_1.TelemetryAttributes.JobFailedReason]: err.message,
|
|
549
|
+
});
|
|
550
|
+
if (result) {
|
|
551
|
+
const [jobData, jobId, rateLimitDelay, delayUntil] = result;
|
|
552
|
+
this.updateDelays(rateLimitDelay, delayUntil);
|
|
553
|
+
return this.nextJobFromJobData(jobData, jobId, token);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
catch (err) {
|
|
557
|
+
this.emit('error', err);
|
|
558
|
+
// It probably means that the job has lost the lock before completion
|
|
559
|
+
// A worker will (or already has) moved the job back
|
|
560
|
+
// to the waiting list (as stalled)
|
|
561
|
+
span === null || span === void 0 ? void 0 : span.recordException(err.message);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
531
565
|
/**
|
|
532
566
|
*
|
|
533
567
|
* Pauses the processing of this queue only for this worker.
|
|
534
568
|
*/
|
|
535
569
|
async pause(doNotWaitActive) {
|
|
536
570
|
await this.trace(enums_1.SpanKind.INTERNAL, 'pause', this.name, async (span) => {
|
|
571
|
+
var _a;
|
|
537
572
|
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
538
573
|
[enums_1.TelemetryAttributes.WorkerId]: this.id,
|
|
539
574
|
[enums_1.TelemetryAttributes.WorkerName]: this.opts.name,
|
|
540
575
|
[enums_1.TelemetryAttributes.WorkerDoNotWaitActive]: doNotWaitActive,
|
|
541
576
|
});
|
|
542
577
|
if (!this.paused) {
|
|
543
|
-
this.paused =
|
|
544
|
-
this.resumeWorker = function () {
|
|
545
|
-
resolve();
|
|
546
|
-
this.paused = null; // Allow pause to be checked externally for paused state.
|
|
547
|
-
this.resumeWorker = null;
|
|
548
|
-
};
|
|
549
|
-
});
|
|
578
|
+
this.paused = true;
|
|
550
579
|
await (!doNotWaitActive && this.whenCurrentJobsFinished());
|
|
580
|
+
(_a = this.stalledCheckStopper) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
551
581
|
this.emit('paused');
|
|
552
582
|
}
|
|
553
583
|
});
|
|
@@ -557,13 +587,16 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
557
587
|
* Resumes processing of this worker (if paused).
|
|
558
588
|
*/
|
|
559
589
|
resume() {
|
|
560
|
-
if (this.
|
|
590
|
+
if (!this.running) {
|
|
561
591
|
this.trace(enums_1.SpanKind.INTERNAL, 'resume', this.name, span => {
|
|
562
592
|
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
563
593
|
[enums_1.TelemetryAttributes.WorkerId]: this.id,
|
|
564
594
|
[enums_1.TelemetryAttributes.WorkerName]: this.opts.name,
|
|
565
595
|
});
|
|
566
|
-
this.
|
|
596
|
+
this.paused = false;
|
|
597
|
+
if (this.processFn) {
|
|
598
|
+
this.run();
|
|
599
|
+
}
|
|
567
600
|
this.emit('resumed');
|
|
568
601
|
});
|
|
569
602
|
}
|
|
@@ -602,17 +635,16 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
602
635
|
if (this.closing) {
|
|
603
636
|
return this.closing;
|
|
604
637
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
[enums_1.TelemetryAttributes.WorkerId]: this.id,
|
|
608
|
-
[enums_1.TelemetryAttributes.WorkerName]: this.opts.name,
|
|
609
|
-
[enums_1.TelemetryAttributes.WorkerForceClose]: force,
|
|
610
|
-
});
|
|
611
|
-
this.closing = (async () => {
|
|
638
|
+
this.closing = (async () => {
|
|
639
|
+
await this.trace(enums_1.SpanKind.INTERNAL, 'close', this.name, async (span) => {
|
|
612
640
|
var _a, _b;
|
|
641
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
642
|
+
[enums_1.TelemetryAttributes.WorkerId]: this.id,
|
|
643
|
+
[enums_1.TelemetryAttributes.WorkerName]: this.opts.name,
|
|
644
|
+
[enums_1.TelemetryAttributes.WorkerForceClose]: force,
|
|
645
|
+
});
|
|
613
646
|
this.emit('closing', 'closing queue');
|
|
614
647
|
(_a = this.abortDelayController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
615
|
-
this.resume();
|
|
616
648
|
// Define the async cleanup functions
|
|
617
649
|
const asyncCleanups = [
|
|
618
650
|
() => {
|
|
@@ -635,9 +667,9 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
635
667
|
(_b = this.stalledCheckStopper) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
636
668
|
this.closed = true;
|
|
637
669
|
this.emit('closed');
|
|
638
|
-
})
|
|
639
|
-
|
|
640
|
-
|
|
670
|
+
});
|
|
671
|
+
})();
|
|
672
|
+
return await this.closing;
|
|
641
673
|
}
|
|
642
674
|
/**
|
|
643
675
|
*
|
|
@@ -667,7 +699,7 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
667
699
|
}
|
|
668
700
|
}
|
|
669
701
|
async stalledChecker() {
|
|
670
|
-
while (!this.closing) {
|
|
702
|
+
while (!(this.closing || this.paused)) {
|
|
671
703
|
try {
|
|
672
704
|
await this.checkConnectionError(() => this.moveStalledJobsToWait());
|
|
673
705
|
}
|
|
@@ -731,8 +763,8 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
731
763
|
else {
|
|
732
764
|
reconnect = false;
|
|
733
765
|
}
|
|
734
|
-
if (this.
|
|
735
|
-
await this.
|
|
766
|
+
if (this.mainLoopRunning) {
|
|
767
|
+
await this.mainLoopRunning;
|
|
736
768
|
}
|
|
737
769
|
reconnect && (await this.blockingConnection.reconnect());
|
|
738
770
|
}
|
|
@@ -774,13 +806,11 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
774
806
|
}
|
|
775
807
|
async moveStalledJobsToWait() {
|
|
776
808
|
await this.trace(enums_1.SpanKind.INTERNAL, 'moveStalledJobsToWait', this.name, async (span) => {
|
|
777
|
-
const
|
|
778
|
-
const [failed, stalled] = await this.scripts.moveStalledJobsToWait();
|
|
809
|
+
const stalled = await this.scripts.moveStalledJobsToWait();
|
|
779
810
|
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
780
811
|
[enums_1.TelemetryAttributes.WorkerId]: this.id,
|
|
781
812
|
[enums_1.TelemetryAttributes.WorkerName]: this.opts.name,
|
|
782
813
|
[enums_1.TelemetryAttributes.WorkerStalledJobs]: stalled,
|
|
783
|
-
[enums_1.TelemetryAttributes.WorkerFailedJobs]: failed,
|
|
784
814
|
});
|
|
785
815
|
stalled.forEach((jobId) => {
|
|
786
816
|
span === null || span === void 0 ? void 0 : span.addEvent('job stalled', {
|
|
@@ -788,31 +818,10 @@ class Worker extends queue_base_1.QueueBase {
|
|
|
788
818
|
});
|
|
789
819
|
this.emit('stalled', jobId, 'active');
|
|
790
820
|
});
|
|
791
|
-
// Todo: check if there any listeners on failed event
|
|
792
|
-
const jobPromises = [];
|
|
793
|
-
for (let i = 0; i < failed.length; i++) {
|
|
794
|
-
jobPromises.push(job_1.Job.fromId(this, failed[i]));
|
|
795
|
-
if ((i + 1) % chunkSize === 0) {
|
|
796
|
-
this.notifyFailedJobs(await Promise.all(jobPromises));
|
|
797
|
-
jobPromises.length = 0;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
this.notifyFailedJobs(await Promise.all(jobPromises));
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
notifyFailedJobs(failedJobs, span) {
|
|
804
|
-
const failedReason = 'job stalled more than allowable limit';
|
|
805
|
-
failedJobs.forEach((job) => {
|
|
806
|
-
span === null || span === void 0 ? void 0 : span.addEvent('job failed', {
|
|
807
|
-
[enums_1.TelemetryAttributes.JobId]: job.id,
|
|
808
|
-
[enums_1.TelemetryAttributes.JobName]: job.name,
|
|
809
|
-
[enums_1.TelemetryAttributes.JobFailedReason]: failedReason,
|
|
810
|
-
});
|
|
811
|
-
this.emit('failed', job, new Error(failedReason), 'active');
|
|
812
821
|
});
|
|
813
822
|
}
|
|
814
823
|
moveLimitedBackToWait(job, token) {
|
|
815
|
-
return
|
|
824
|
+
return job.moveToWait(token);
|
|
816
825
|
}
|
|
817
826
|
}
|
|
818
827
|
exports.Worker = Worker;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
[8] parent? {id, queueKey}
|
|
27
27
|
[9] repeat job key
|
|
28
28
|
[10] deduplication key
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
ARGV[2] Json stringified job data
|
|
31
31
|
ARGV[3] msgpacked options
|
|
32
32
|
|
|
@@ -56,9 +56,8 @@ local deduplicationKey = args[10]
|
|
|
56
56
|
local parentData
|
|
57
57
|
|
|
58
58
|
-- Includes
|
|
59
|
-
--- @include "includes/
|
|
59
|
+
--- @include "includes/addDelayedJob"
|
|
60
60
|
--- @include "includes/deduplicateJob"
|
|
61
|
-
--- @include "includes/getDelayedScore"
|
|
62
61
|
--- @include "includes/getOrSetMaxEvents"
|
|
63
62
|
--- @include "includes/handleDuplicatedJob"
|
|
64
63
|
--- @include "includes/storeJob"
|
|
@@ -90,26 +89,16 @@ else
|
|
|
90
89
|
end
|
|
91
90
|
end
|
|
92
91
|
|
|
93
|
-
local deduplicationJobId = deduplicateJob(
|
|
94
|
-
|
|
92
|
+
local deduplicationJobId = deduplicateJob(opts['de'], jobId, delayedKey, deduplicationKey,
|
|
93
|
+
eventsKey, maxEvents, args[1])
|
|
95
94
|
if deduplicationJobId then
|
|
96
95
|
return deduplicationJobId
|
|
97
96
|
end
|
|
98
97
|
|
|
99
|
-
-- Store the job.
|
|
100
98
|
local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
|
|
101
|
-
|
|
102
|
-
repeatJobKey)
|
|
103
|
-
|
|
104
|
-
local score, delayedTimestamp = getDelayedScore(delayedKey, timestamp, tonumber(delay))
|
|
105
|
-
|
|
106
|
-
rcall("ZADD", delayedKey, score, jobId)
|
|
107
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
|
108
|
-
"jobId", jobId, "delay", delayedTimestamp)
|
|
99
|
+
opts, timestamp, parentKey, parentData, repeatJobKey)
|
|
109
100
|
|
|
110
|
-
|
|
111
|
-
local markerKey = KEYS[1]
|
|
112
|
-
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
101
|
+
addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, KEYS[1], delay)
|
|
113
102
|
|
|
114
103
|
-- Check if this job is a child of another job, if so add it to the parents dependencies
|
|
115
104
|
if parentDependenciesKey ~= nil then
|