@tachybase/plugin-adapter-bullmq 0.23.8
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/.turbo/turbo-build.log +3 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +1 -0
- package/dist/externalVersion.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/node_modules/@bull-board/api/bullAdapter.d.ts +1 -0
- package/dist/node_modules/@bull-board/api/bullAdapter.js +1 -0
- package/dist/node_modules/@bull-board/api/bullMQAdapter.d.ts +1 -0
- package/dist/node_modules/@bull-board/api/bullMQAdapter.js +1 -0
- package/dist/node_modules/@bull-board/api/dist/src/constants/statuses.d.ts +11 -0
- package/dist/node_modules/@bull-board/api/dist/src/constants/statuses.js +15 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/addJob.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/addJob.js +18 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/cleanAll.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/cleanAll.js +15 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/cleanJob.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/cleanJob.js +14 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/emptyQueue.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/emptyQueue.js +10 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/entryPoint.d.ts +5 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/entryPoint.js +21 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/error.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/error.js +14 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/job.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/job.js +20 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/jobLogs.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/jobLogs.js +16 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseQueue.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseQueue.js +10 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/promotJob.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/promotJob.js +14 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/promoteAll.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/promoteAll.js +10 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/queues.d.ts +4 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/queues.js +76 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/redisStats.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/redisStats.js +33 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeQueue.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeQueue.js +10 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/retryAll.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/retryAll.js +12 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/retryJob.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/retryJob.js +15 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/updateJobData.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/handlers/updateJobData.js +20 -0
- package/dist/node_modules/@bull-board/api/dist/src/index.d.ts +12 -0
- package/dist/node_modules/@bull-board/api/dist/src/index.js +1 -0
- package/dist/node_modules/@bull-board/api/dist/src/providers/job.d.ts +3 -0
- package/dist/node_modules/@bull-board/api/dist/src/providers/job.js +19 -0
- package/dist/node_modules/@bull-board/api/dist/src/providers/queue.d.ts +5 -0
- package/dist/node_modules/@bull-board/api/dist/src/providers/queue.js +20 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.d.ts +31 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.js +27 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bull.d.ts +23 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bull.js +87 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bullMQ.d.ts +22 -0
- package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bullMQ.js +91 -0
- package/dist/node_modules/@bull-board/api/dist/src/queuesApi.d.ts +9 -0
- package/dist/node_modules/@bull-board/api/dist/src/queuesApi.js +32 -0
- package/dist/node_modules/@bull-board/api/dist/src/routes.d.ts +2 -0
- package/dist/node_modules/@bull-board/api/dist/src/routes.js +96 -0
- package/dist/node_modules/@bull-board/api/dist/typings/app.d.ts +203 -0
- package/dist/node_modules/@bull-board/api/dist/typings/app.js +3 -0
- package/dist/node_modules/@bull-board/api/dist/typings/responses.d.ts +8 -0
- package/dist/node_modules/@bull-board/api/dist/typings/responses.js +3 -0
- package/dist/node_modules/@bull-board/api/dist/typings/utils.d.ts +1 -0
- package/dist/node_modules/@bull-board/api/dist/typings/utils.js +3 -0
- package/dist/node_modules/@bull-board/api/package.json +1 -0
- package/dist/node_modules/@bull-board/koa/dist/KoaAdapter.d.ts +23 -0
- package/dist/node_modules/@bull-board/koa/dist/KoaAdapter.js +125 -0
- package/dist/node_modules/@bull-board/koa/dist/index.d.ts +1 -0
- package/dist/node_modules/@bull-board/koa/dist/index.js +415 -0
- package/dist/node_modules/@bull-board/koa/node_modules/.bin/ejs +17 -0
- package/dist/node_modules/@bull-board/koa/package.json +1 -0
- package/dist/node_modules/bullmq/LICENSE +21 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/async-fifo-queue.js +129 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/backoffs.js +48 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/child-pool.js +71 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/child-processor.js +154 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/child.js +210 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/delayed-error.js +20 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/index.js +8 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/rate-limit-error.js +19 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/unrecoverable-error.js +20 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/errors/waiting-children-error.js +20 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/flow-producer.js +339 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/index.js +25 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/job-scheduler.js +221 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/job.js +893 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/main-base.js +44 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/main-worker.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/main-worker.js +10 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/main.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/main.js +10 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-base.js +155 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-events-producer.js +42 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-events.js +125 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-getters.js +450 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/queue-keys.js +43 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/queue.js +635 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/redis-connection.js +270 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/repeat.js +204 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/sandbox.js +75 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/scripts.js +1035 -0
- package/dist/node_modules/bullmq/dist/cjs/classes/worker.js +819 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addDelayedJob-6.lua +119 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-2.lua +91 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addLog-2.lua +30 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addParentJob-4.lua +104 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addPrioritizedJob-8.lua +117 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addRepeatableJob-2.lua +84 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/addStandardJob-8.lua +122 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/changeDelay-4.lua +55 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/changePriority-7.lua +68 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/cleanJobsInSet-3.lua +55 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/drain-5.lua +41 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/extendLock-2.lua +23 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/extendLocks-1.lua +44 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getCounts-1.lua +36 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getCountsPerPriority-4.lua +35 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getJobScheduler-1.lua +19 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getRanges-1.lua +70 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getRateLimitTtl-1.lua +20 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getState-8.lua +65 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/getStateV2-8.lua +58 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addBaseMarkerIfNeeded.lua +9 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobInTargetList.lua +11 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobWithPriority.lua +14 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/batches.lua +18 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/checkItemInList.lua +12 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanList.lua +47 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanSet.lua +66 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/collectMetrics.lua +46 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/deduplicateJob.lua +24 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/destructureJobKey.lua +12 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/findPage.lua +70 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getDelayedScore.lua +25 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getJobsInZset.lua +13 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +12 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getOrSetMaxEvents.lua +11 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getRateLimitTTL.lua +17 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getTargetQueueList.lua +22 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getTimestamp.lua +19 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/getZSetItems.lua +7 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/handleDuplicatedJob.lua +26 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/isLocked.lua +33 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/isQueueMaxed.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/isQueuePaused.lua +7 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/isQueuePausedOrMaxed.lua +18 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveJobFromPriorityToActive.lua +13 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +53 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +55 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/prepareJobForProcessing.lua +50 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/promoteDelayedJobs.lua +40 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/pushBackJobWithPriority.lua +9 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKey.lua +11 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +14 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJob.lua +17 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobFromAnyState.lua +35 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobKeys.lua +8 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobs.lua +13 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobsByMaxAge.lua +16 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobsByMaxCount.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobsOnFail.lua +36 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeListJobs.lua +17 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeLock.lua +19 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeParentDependencyKey.lua +90 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeZSetJobs.lua +27 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJob.lua +36 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/trimEvents.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateExistingJobsParent.lua +27 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateJobFields.lua +11 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +13 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/isFinished-3.lua +48 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/isJobInList-1.lua +16 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/isMaxed-2.lua +17 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-10.lua +60 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveJobsToWait-8.lua +73 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-9.lua +156 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToActive-11.lua +93 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToDelayed-8.lua +77 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToFinished-14.lua +283 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-5.lua +68 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/obliterate-2.lua +118 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/paginate-1.lua +49 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/pause-7.lua +42 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/promote-9.lua +62 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/releaseLock-1.lua +19 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/removeChildDependency-1.lua +34 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/removeJob-2.lua +92 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/removeJobScheduler-3.lua +43 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/removeRepeatable-3.lua +58 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/reprocessJob-8.lua +49 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/retryJob-11.lua +82 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/saveStacktrace-1.lua +19 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/updateData-1.lua +20 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/updateProgress-3.lua +33 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/updateRepeatableJobMillis-1.lua +28 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/child-command.js +10 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/error-code.js +15 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/index.js +9 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/metrics-time.js +15 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/parent-command.js +16 -0
- package/dist/node_modules/bullmq/dist/cjs/enums/telemetry-attributes.js +48 -0
- package/dist/node_modules/bullmq/dist/cjs/index.js +1 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/advanced-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/backoff-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/base-job-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/child-message.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/connection.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/debounce-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/flow-job.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/index.js +32 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/ioredis-events.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/job-json.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/job-scheduler-json.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/keep-jobs.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/metrics-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/metrics.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/minimal-job.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/parent-message.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/parent.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/queue-options.js +9 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/rate-limiter-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/redis-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/redis-streams.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/repeat-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/repeatable-job.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/repeatable-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/sandboxed-job-processor.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/sandboxed-job.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/sandboxed-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/telemetry.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/interfaces/worker-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addDelayedJob-6.js +373 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-2.js +237 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addLog-2.js +33 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addParentJob-4.js +340 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addPrioritizedJob-8.js +350 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addRepeatableJob-2.js +230 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/addStandardJob-8.js +354 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/changeDelay-4.js +107 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/changePriority-7.js +122 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/cleanJobsInSet-3.js +350 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/drain-5.js +258 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/extendLock-2.js +30 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/extendLocks-1.js +46 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getCounts-1.js +42 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getCountsPerPriority-4.js +46 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getJobScheduler-1.js +23 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getRanges-1.js +73 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getRateLimitTtl-1.js +39 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getState-8.js +73 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/getStateV2-8.js +57 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/index.js +49 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/isFinished-3.js +49 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/isJobInList-1.js +32 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/isMaxed-2.js +34 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobFromActiveToWait-10.js +110 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobsToWait-8.js +118 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-9.js +529 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToActive-11.js +233 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToDelayed-8.js +156 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToFinished-14.js +798 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-5.js +83 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/obliterate-2.js +327 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/paginate-1.js +110 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/pause-7.js +67 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/promote-9.js +105 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/releaseLock-1.js +25 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeChildDependency-1.js +165 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeJob-2.js +292 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeJobScheduler-3.js +49 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/removeRepeatable-3.js +63 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/reprocessJob-8.js +96 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/retryJob-11.js +193 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/saveStacktrace-1.js +27 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/updateData-1.js +26 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/updateProgress-3.js +46 -0
- package/dist/node_modules/bullmq/dist/cjs/scripts/updateRepeatableJobMillis-1.js +33 -0
- package/dist/node_modules/bullmq/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -0
- package/dist/node_modules/bullmq/dist/cjs/types/backoff-strategy.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/finished-status.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/index.js +12 -0
- package/dist/node_modules/bullmq/dist/cjs/types/job-json-sandbox.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/job-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/job-scheduler-template-options.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/job-type.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/minimal-queue.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/types/repeat-strategy.js +3 -0
- package/dist/node_modules/bullmq/dist/cjs/utils.js +288 -0
- package/dist/node_modules/bullmq/dist/cjs/version.js +5 -0
- package/dist/node_modules/bullmq/dist/esm/classes/async-fifo-queue.d.ts +37 -0
- package/dist/node_modules/bullmq/dist/esm/classes/async-fifo-queue.js +125 -0
- package/dist/node_modules/bullmq/dist/esm/classes/backoffs.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/classes/backoffs.js +44 -0
- package/dist/node_modules/bullmq/dist/esm/classes/child-pool.d.ts +23 -0
- package/dist/node_modules/bullmq/dist/esm/classes/child-pool.js +67 -0
- package/dist/node_modules/bullmq/dist/esm/classes/child-processor.d.ts +37 -0
- package/dist/node_modules/bullmq/dist/esm/classes/child-processor.js +150 -0
- package/dist/node_modules/bullmq/dist/esm/classes/child.d.ts +35 -0
- package/dist/node_modules/bullmq/dist/esm/classes/child.js +206 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/delayed-error.d.ts +11 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/delayed-error.js +16 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/index.d.ts +4 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/index.js +5 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/rate-limit-error.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/rate-limit-error.js +15 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/unrecoverable-error.d.ts +11 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/unrecoverable-error.js +16 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-children-error.d.ts +11 -0
- package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-children-error.js +16 -0
- package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.d.ts +179 -0
- package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.js +335 -0
- package/dist/node_modules/bullmq/dist/esm/classes/index.d.ts +19 -0
- package/dist/node_modules/bullmq/dist/esm/classes/index.js +22 -0
- package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.d.ts +24 -0
- package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.js +216 -0
- package/dist/node_modules/bullmq/dist/esm/classes/job.d.ts +425 -0
- package/dist/node_modules/bullmq/dist/esm/classes/job.js +889 -0
- package/dist/node_modules/bullmq/dist/esm/classes/main-base.d.ts +4 -0
- package/dist/node_modules/bullmq/dist/esm/classes/main-base.js +42 -0
- package/dist/node_modules/bullmq/dist/esm/classes/main-worker.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/esm/classes/main-worker.js +8 -0
- package/dist/node_modules/bullmq/dist/esm/classes/main.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/esm/classes/main.js +8 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-base.d.ts +83 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-base.js +151 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-events-producer.d.ts +21 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-events-producer.js +38 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-events.d.ts +201 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-events.js +121 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.d.ts +235 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.js +447 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-keys.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue-keys.js +39 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue.d.ts +406 -0
- package/dist/node_modules/bullmq/dist/esm/classes/queue.js +631 -0
- package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.d.ts +46 -0
- package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.js +266 -0
- package/dist/node_modules/bullmq/dist/esm/classes/repeat.d.ts +25 -0
- package/dist/node_modules/bullmq/dist/esm/classes/repeat.js +199 -0
- package/dist/node_modules/bullmq/dist/esm/classes/sandbox.d.ts +4 -0
- package/dist/node_modules/bullmq/dist/esm/classes/sandbox.js +73 -0
- package/dist/node_modules/bullmq/dist/esm/classes/scripts.d.ts +160 -0
- package/dist/node_modules/bullmq/dist/esm/classes/scripts.js +1031 -0
- package/dist/node_modules/bullmq/dist/esm/classes/worker.d.ts +231 -0
- package/dist/node_modules/bullmq/dist/esm/classes/worker.js +815 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addDelayedJob-6.lua +119 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-2.lua +91 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addLog-2.lua +30 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addParentJob-4.lua +104 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addPrioritizedJob-8.lua +117 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addRepeatableJob-2.lua +84 -0
- package/dist/node_modules/bullmq/dist/esm/commands/addStandardJob-8.lua +122 -0
- package/dist/node_modules/bullmq/dist/esm/commands/changeDelay-4.lua +55 -0
- package/dist/node_modules/bullmq/dist/esm/commands/changePriority-7.lua +68 -0
- package/dist/node_modules/bullmq/dist/esm/commands/cleanJobsInSet-3.lua +55 -0
- package/dist/node_modules/bullmq/dist/esm/commands/drain-5.lua +41 -0
- package/dist/node_modules/bullmq/dist/esm/commands/extendLock-2.lua +23 -0
- package/dist/node_modules/bullmq/dist/esm/commands/extendLocks-1.lua +44 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getCounts-1.lua +36 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getCountsPerPriority-4.lua +35 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getJobScheduler-1.lua +19 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getRanges-1.lua +70 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getRateLimitTtl-1.lua +20 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getState-8.lua +65 -0
- package/dist/node_modules/bullmq/dist/esm/commands/getStateV2-8.lua +58 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addBaseMarkerIfNeeded.lua +9 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobInTargetList.lua +11 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobWithPriority.lua +14 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/batches.lua +18 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/checkItemInList.lua +12 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanList.lua +47 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanSet.lua +66 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/collectMetrics.lua +46 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/deduplicateJob.lua +24 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/destructureJobKey.lua +12 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/findPage.lua +70 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getDelayedScore.lua +25 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getJobsInZset.lua +13 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getNextDelayedTimestamp.lua +12 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getOrSetMaxEvents.lua +11 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getRateLimitTTL.lua +17 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getTargetQueueList.lua +22 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getTimestamp.lua +19 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/getZSetItems.lua +7 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/handleDuplicatedJob.lua +26 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/isLocked.lua +33 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/isQueueMaxed.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/isQueuePaused.lua +7 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/isQueuePausedOrMaxed.lua +18 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveJobFromPriorityToActive.lua +13 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +53 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +55 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/prepareJobForProcessing.lua +50 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/promoteDelayedJobs.lua +40 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/pushBackJobWithPriority.lua +9 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKey.lua +11 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +14 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJob.lua +17 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobFromAnyState.lua +35 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobKeys.lua +8 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobs.lua +13 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobsByMaxAge.lua +16 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobsByMaxCount.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobsOnFail.lua +36 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeListJobs.lua +17 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeLock.lua +19 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeParentDependencyKey.lua +90 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/removeZSetJobs.lua +27 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJob.lua +36 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/trimEvents.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/updateExistingJobsParent.lua +27 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/updateJobFields.lua +11 -0
- package/dist/node_modules/bullmq/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +13 -0
- package/dist/node_modules/bullmq/dist/esm/commands/isFinished-3.lua +48 -0
- package/dist/node_modules/bullmq/dist/esm/commands/isJobInList-1.lua +16 -0
- package/dist/node_modules/bullmq/dist/esm/commands/isMaxed-2.lua +17 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-10.lua +60 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveJobsToWait-8.lua +73 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-9.lua +156 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveToActive-11.lua +93 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveToDelayed-8.lua +77 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveToFinished-14.lua +283 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-5.lua +68 -0
- package/dist/node_modules/bullmq/dist/esm/commands/obliterate-2.lua +118 -0
- package/dist/node_modules/bullmq/dist/esm/commands/paginate-1.lua +49 -0
- package/dist/node_modules/bullmq/dist/esm/commands/pause-7.lua +42 -0
- package/dist/node_modules/bullmq/dist/esm/commands/promote-9.lua +62 -0
- package/dist/node_modules/bullmq/dist/esm/commands/releaseLock-1.lua +19 -0
- package/dist/node_modules/bullmq/dist/esm/commands/removeChildDependency-1.lua +34 -0
- package/dist/node_modules/bullmq/dist/esm/commands/removeJob-2.lua +92 -0
- package/dist/node_modules/bullmq/dist/esm/commands/removeJobScheduler-3.lua +43 -0
- package/dist/node_modules/bullmq/dist/esm/commands/removeRepeatable-3.lua +58 -0
- package/dist/node_modules/bullmq/dist/esm/commands/reprocessJob-8.lua +49 -0
- package/dist/node_modules/bullmq/dist/esm/commands/retryJob-11.lua +82 -0
- package/dist/node_modules/bullmq/dist/esm/commands/saveStacktrace-1.lua +19 -0
- package/dist/node_modules/bullmq/dist/esm/commands/updateData-1.lua +20 -0
- package/dist/node_modules/bullmq/dist/esm/commands/updateProgress-3.lua +33 -0
- package/dist/node_modules/bullmq/dist/esm/commands/updateRepeatableJobMillis-1.lua +28 -0
- package/dist/node_modules/bullmq/dist/esm/enums/child-command.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/enums/child-command.js +7 -0
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.js +12 -0
- package/dist/node_modules/bullmq/dist/esm/enums/index.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/enums/index.js +6 -0
- package/dist/node_modules/bullmq/dist/esm/enums/metrics-time.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/enums/metrics-time.js +12 -0
- package/dist/node_modules/bullmq/dist/esm/enums/parent-command.d.ts +11 -0
- package/dist/node_modules/bullmq/dist/esm/enums/parent-command.js +13 -0
- package/dist/node_modules/bullmq/dist/esm/enums/telemetry-attributes.d.ts +42 -0
- package/dist/node_modules/bullmq/dist/esm/enums/telemetry-attributes.js +45 -0
- package/dist/node_modules/bullmq/dist/esm/index.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/index.js +6 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/advanced-options.d.ts +18 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/advanced-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/backoff-options.d.ts +15 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/backoff-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/base-job-options.d.ts +100 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/base-job-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/child-message.d.ts +6 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/child-message.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/connection.d.ts +8 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/connection.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.d.ts +13 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/flow-job.d.ts +19 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/flow-job.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/index.d.ts +28 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/index.js +29 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/ioredis-events.d.ts +8 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/ioredis-events.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/job-json.d.ts +47 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/job-json.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/job-scheduler-json.d.ts +16 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/job-scheduler-json.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/keep-jobs.d.ts +17 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/keep-jobs.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/metrics-options.d.ts +12 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/metrics-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/metrics.d.ts +9 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/metrics.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/minimal-job.d.ts +133 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/minimal-job.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent-message.d.ts +8 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent-message.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent.d.ts +20 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/parent.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/queue-options.d.ts +97 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/queue-options.js +6 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/rate-limiter-options.d.ts +12 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/rate-limiter-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/redis-options.d.ts +8 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/redis-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/redis-streams.d.ts +4 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/redis-streams.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeat-options.d.ts +51 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeat-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-job.d.ts +10 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-job.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-options.d.ts +7 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job-processor.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job-processor.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job.d.ts +13 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-options.d.ts +28 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/telemetry.d.ts +150 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/telemetry.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/worker-options.d.ts +133 -0
- package/dist/node_modules/bullmq/dist/esm/interfaces/worker-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addDelayedJob-6.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addDelayedJob-6.js +370 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-2.js +234 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addLog-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addLog-2.js +30 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addParentJob-4.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addParentJob-4.js +337 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addPrioritizedJob-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addPrioritizedJob-8.js +347 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addRepeatableJob-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addRepeatableJob-2.js +227 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addStandardJob-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/addStandardJob-8.js +351 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/changeDelay-4.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/changeDelay-4.js +104 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/changePriority-7.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/changePriority-7.js +119 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/cleanJobsInSet-3.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/cleanJobsInSet-3.js +347 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/drain-5.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/drain-5.js +255 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/extendLock-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/extendLock-2.js +27 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/extendLocks-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/extendLocks-1.js +43 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getCounts-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getCounts-1.js +39 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getCountsPerPriority-4.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getCountsPerPriority-4.js +43 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getJobScheduler-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getJobScheduler-1.js +20 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getRanges-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getRanges-1.js +70 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getRateLimitTtl-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getRateLimitTtl-1.js +36 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getState-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getState-8.js +70 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getStateV2-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/getStateV2-8.js +54 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/index.d.ts +45 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/index.js +46 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/isFinished-3.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/isFinished-3.js +46 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/isJobInList-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/isJobInList-1.js +29 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/isMaxed-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/isMaxed-2.js +31 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobFromActiveToWait-10.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobFromActiveToWait-10.js +107 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobsToWait-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobsToWait-8.js +115 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-9.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-9.js +526 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToActive-11.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToActive-11.js +230 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToDelayed-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToDelayed-8.js +153 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToFinished-14.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToFinished-14.js +795 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-5.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-5.js +80 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/obliterate-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/obliterate-2.js +324 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/paginate-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/paginate-1.js +107 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/pause-7.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/pause-7.js +64 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/promote-9.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/promote-9.js +102 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/releaseLock-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/releaseLock-1.js +22 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeChildDependency-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeChildDependency-1.js +162 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeJob-2.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeJob-2.js +289 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeJobScheduler-3.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeJobScheduler-3.js +46 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeRepeatable-3.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/removeRepeatable-3.js +60 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/reprocessJob-8.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/reprocessJob-8.js +93 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/retryJob-11.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/retryJob-11.js +190 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/saveStacktrace-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/saveStacktrace-1.js +24 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateData-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateData-1.js +23 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateProgress-3.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateProgress-3.js +43 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateRepeatableJobMillis-1.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/scripts/updateRepeatableJobMillis-1.js +30 -0
- package/dist/node_modules/bullmq/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/node_modules/bullmq/dist/esm/types/backoff-strategy.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/backoff-strategy.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/finished-status.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/finished-status.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/index.d.ts +8 -0
- package/dist/node_modules/bullmq/dist/esm/types/index.js +9 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-json-sandbox.d.ts +5 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-json-sandbox.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-options.d.ts +81 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-scheduler-template-options.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-scheduler-template-options.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-type.d.ts +3 -0
- package/dist/node_modules/bullmq/dist/esm/types/job-type.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/minimal-queue.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/minimal-queue.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/repeat-strategy.d.ts +2 -0
- package/dist/node_modules/bullmq/dist/esm/types/repeat-strategy.js +2 -0
- package/dist/node_modules/bullmq/dist/esm/utils.d.ts +72 -0
- package/dist/node_modules/bullmq/dist/esm/utils.js +263 -0
- package/dist/node_modules/bullmq/dist/esm/version.d.ts +1 -0
- package/dist/node_modules/bullmq/dist/esm/version.js +2 -0
- package/dist/node_modules/bullmq/node_modules/.bin/semver +17 -0
- package/dist/node_modules/bullmq/node_modules/.bin/uuid +17 -0
- package/dist/node_modules/bullmq/package.json +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +63 -0
- package/package.json +18 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
5
|
+
// Note: this Polyfill is only needed for Node versions < 15.4.0
|
|
6
|
+
import { AbortController } from 'node-abort-controller';
|
|
7
|
+
import { delay, DELAY_TIME_1, isNotConnectionError, isRedisInstance, } from '../utils';
|
|
8
|
+
import { QueueBase } from './queue-base';
|
|
9
|
+
import { Repeat } from './repeat';
|
|
10
|
+
import { ChildPool } from './child-pool';
|
|
11
|
+
import { Job } from './job';
|
|
12
|
+
import { RedisConnection } from './redis-connection';
|
|
13
|
+
import sandbox from './sandbox';
|
|
14
|
+
import { AsyncFifoQueue } from './async-fifo-queue';
|
|
15
|
+
import { DelayedError, RateLimitError, RATE_LIMIT_ERROR, WaitingChildrenError, } from './errors';
|
|
16
|
+
import { SpanKind, TelemetryAttributes } from '../enums';
|
|
17
|
+
import { JobScheduler } from './job-scheduler';
|
|
18
|
+
// 10 seconds is the maximum time a BZPOPMIN can block.
|
|
19
|
+
const maximumBlockTimeout = 10;
|
|
20
|
+
// 30 seconds is the maximum limit until.
|
|
21
|
+
const maximumLimitUntil = 30000;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* This class represents a worker that is able to process jobs from the queue.
|
|
25
|
+
* As soon as the class is instantiated and a connection to Redis is established
|
|
26
|
+
* it will start processing jobs.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export class Worker extends QueueBase {
|
|
30
|
+
static RateLimitError() {
|
|
31
|
+
return new RateLimitError();
|
|
32
|
+
}
|
|
33
|
+
constructor(name, processor, opts, Connection) {
|
|
34
|
+
super(name, Object.assign(Object.assign({}, opts), { blockingConnection: true }), Connection);
|
|
35
|
+
this.abortDelayController = null;
|
|
36
|
+
this.blockUntil = 0;
|
|
37
|
+
this.drained = false;
|
|
38
|
+
this.extendLocksTimer = null;
|
|
39
|
+
this.limitUntil = 0;
|
|
40
|
+
this.waiting = null;
|
|
41
|
+
this.running = false;
|
|
42
|
+
if (!opts || !opts.connection) {
|
|
43
|
+
throw new Error('Worker requires a connection');
|
|
44
|
+
}
|
|
45
|
+
this.opts = Object.assign({ drainDelay: 5, concurrency: 1, lockDuration: 30000, maxStalledCount: 1, stalledInterval: 30000, autorun: true, runRetryDelay: 15000 }, this.opts);
|
|
46
|
+
if (this.opts.stalledInterval <= 0) {
|
|
47
|
+
throw new Error('stalledInterval must be greater than 0');
|
|
48
|
+
}
|
|
49
|
+
if (this.opts.drainDelay <= 0) {
|
|
50
|
+
throw new Error('drainDelay must be greater than 0');
|
|
51
|
+
}
|
|
52
|
+
this.concurrency = this.opts.concurrency;
|
|
53
|
+
this.opts.lockRenewTime =
|
|
54
|
+
this.opts.lockRenewTime || this.opts.lockDuration / 2;
|
|
55
|
+
this.id = v4();
|
|
56
|
+
if (processor) {
|
|
57
|
+
if (typeof processor === 'function') {
|
|
58
|
+
this.processFn = processor;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// SANDBOXED
|
|
62
|
+
if (processor instanceof URL) {
|
|
63
|
+
if (!fs.existsSync(processor)) {
|
|
64
|
+
throw new Error(`URL ${processor} does not exist in the local file system`);
|
|
65
|
+
}
|
|
66
|
+
processor = processor.href;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const supportedFileTypes = ['.js', '.ts', '.flow', '.cjs'];
|
|
70
|
+
const processorFile = processor +
|
|
71
|
+
(supportedFileTypes.includes(path.extname(processor)) ? '' : '.js');
|
|
72
|
+
if (!fs.existsSync(processorFile)) {
|
|
73
|
+
throw new Error(`File ${processorFile} does not exist`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Separate paths so that bundling tools can resolve dependencies easier
|
|
77
|
+
const dirname = path.dirname(module.filename || __filename);
|
|
78
|
+
const workerThreadsMainFile = path.join(dirname, 'main-worker.js');
|
|
79
|
+
const spawnProcessMainFile = path.join(dirname, 'main.js');
|
|
80
|
+
let mainFilePath = this.opts.useWorkerThreads
|
|
81
|
+
? workerThreadsMainFile
|
|
82
|
+
: spawnProcessMainFile;
|
|
83
|
+
try {
|
|
84
|
+
fs.statSync(mainFilePath); // would throw if file not exists
|
|
85
|
+
}
|
|
86
|
+
catch (_) {
|
|
87
|
+
const mainFile = this.opts.useWorkerThreads
|
|
88
|
+
? 'main-worker.js'
|
|
89
|
+
: 'main.js';
|
|
90
|
+
mainFilePath = path.join(process.cwd(), `dist/cjs/classes/${mainFile}`);
|
|
91
|
+
fs.statSync(mainFilePath);
|
|
92
|
+
}
|
|
93
|
+
this.childPool = new ChildPool({
|
|
94
|
+
mainFile: mainFilePath,
|
|
95
|
+
useWorkerThreads: this.opts.useWorkerThreads,
|
|
96
|
+
workerForkOptions: this.opts.workerForkOptions,
|
|
97
|
+
workerThreadsOptions: this.opts.workerThreadsOptions,
|
|
98
|
+
});
|
|
99
|
+
this.processFn = sandbox(processor, this.childPool).bind(this);
|
|
100
|
+
}
|
|
101
|
+
if (this.opts.autorun) {
|
|
102
|
+
this.run().catch(error => this.emit('error', error));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const connectionName = this.clientName() + (this.opts.name ? `:w:${this.opts.name}` : '');
|
|
106
|
+
this.blockingConnection = new RedisConnection(isRedisInstance(opts.connection)
|
|
107
|
+
? opts.connection.duplicate({ connectionName })
|
|
108
|
+
: Object.assign(Object.assign({}, opts.connection), { connectionName }), false, true, opts.skipVersionCheck);
|
|
109
|
+
this.blockingConnection.on('error', error => this.emit('error', error));
|
|
110
|
+
this.blockingConnection.on('ready', () => setTimeout(() => this.emit('ready'), 0));
|
|
111
|
+
}
|
|
112
|
+
emit(event, ...args) {
|
|
113
|
+
return super.emit(event, ...args);
|
|
114
|
+
}
|
|
115
|
+
off(eventName, listener) {
|
|
116
|
+
super.off(eventName, listener);
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
on(event, listener) {
|
|
120
|
+
super.on(event, listener);
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
once(event, listener) {
|
|
124
|
+
super.once(event, listener);
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
callProcessJob(job, token) {
|
|
128
|
+
return this.processFn(job, token);
|
|
129
|
+
}
|
|
130
|
+
createJob(data, jobId) {
|
|
131
|
+
return this.Job.fromJSON(this, data, jobId);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
* Waits until the worker is ready to start processing jobs.
|
|
136
|
+
* In general only useful when writing tests.
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
async waitUntilReady() {
|
|
140
|
+
await super.waitUntilReady();
|
|
141
|
+
return this.blockingConnection.client;
|
|
142
|
+
}
|
|
143
|
+
set concurrency(concurrency) {
|
|
144
|
+
if (typeof concurrency !== 'number' ||
|
|
145
|
+
concurrency < 1 ||
|
|
146
|
+
!isFinite(concurrency)) {
|
|
147
|
+
throw new Error('concurrency must be a finite number greater than 0');
|
|
148
|
+
}
|
|
149
|
+
this._concurrency = concurrency;
|
|
150
|
+
}
|
|
151
|
+
get concurrency() {
|
|
152
|
+
return this._concurrency;
|
|
153
|
+
}
|
|
154
|
+
get repeat() {
|
|
155
|
+
return new Promise(async (resolve) => {
|
|
156
|
+
if (!this._repeat) {
|
|
157
|
+
const connection = await this.client;
|
|
158
|
+
this._repeat = new Repeat(this.name, Object.assign(Object.assign({}, this.opts), { connection }));
|
|
159
|
+
this._repeat.on('error', e => this.emit.bind(this, e));
|
|
160
|
+
}
|
|
161
|
+
resolve(this._repeat);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
get jobScheduler() {
|
|
165
|
+
return new Promise(async (resolve) => {
|
|
166
|
+
if (!this._jobScheduler) {
|
|
167
|
+
const connection = await this.client;
|
|
168
|
+
this._jobScheduler = new JobScheduler(this.name, Object.assign(Object.assign({}, this.opts), { connection }));
|
|
169
|
+
this._jobScheduler.on('error', e => this.emit.bind(this, e));
|
|
170
|
+
}
|
|
171
|
+
resolve(this._jobScheduler);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async run() {
|
|
175
|
+
if (!this.processFn) {
|
|
176
|
+
throw new Error('No process function is defined.');
|
|
177
|
+
}
|
|
178
|
+
if (this.running) {
|
|
179
|
+
throw new Error('Worker is already running.');
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
this.running = true;
|
|
183
|
+
if (this.closing) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
await this.startStalledCheckTimer();
|
|
187
|
+
const jobsInProgress = new Set();
|
|
188
|
+
this.startLockExtenderTimer(jobsInProgress);
|
|
189
|
+
const asyncFifoQueue = (this.asyncFifoQueue =
|
|
190
|
+
new AsyncFifoQueue());
|
|
191
|
+
let tokenPostfix = 0;
|
|
192
|
+
const client = await this.client;
|
|
193
|
+
const bclient = await this.blockingConnection.client;
|
|
194
|
+
/**
|
|
195
|
+
* This is the main loop in BullMQ. Its goals are to fetch jobs from the queue
|
|
196
|
+
* as efficiently as possible, providing concurrency and minimal unnecessary calls
|
|
197
|
+
* to Redis.
|
|
198
|
+
*/
|
|
199
|
+
while (!this.closing) {
|
|
200
|
+
let numTotal = asyncFifoQueue.numTotal();
|
|
201
|
+
/**
|
|
202
|
+
* This inner loop tries to fetch jobs concurrently, but if we are waiting for a job
|
|
203
|
+
* to arrive at the queue we should not try to fetch more jobs (as it would be pointless)
|
|
204
|
+
*/
|
|
205
|
+
while (!this.waiting &&
|
|
206
|
+
numTotal < this._concurrency &&
|
|
207
|
+
(!this.limitUntil || numTotal == 0)) {
|
|
208
|
+
const token = `${this.id}:${tokenPostfix++}`;
|
|
209
|
+
const fetchedJob = this.retryIfFailed(() => this._getNextJob(client, bclient, token, { block: true }), this.opts.runRetryDelay);
|
|
210
|
+
asyncFifoQueue.add(fetchedJob);
|
|
211
|
+
numTotal = asyncFifoQueue.numTotal();
|
|
212
|
+
if (this.waiting && numTotal > 1) {
|
|
213
|
+
// We are waiting for jobs but we have others that we could start processing already
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
// We await here so that we fetch jobs in sequence, this is important to avoid unnecessary calls
|
|
217
|
+
// to Redis in high concurrency scenarios.
|
|
218
|
+
const job = await fetchedJob;
|
|
219
|
+
// No more jobs waiting but we have others that could start processing already
|
|
220
|
+
if (!job && numTotal > 1) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
// If there are potential jobs to be processed and blockUntil is set, we should exit to avoid waiting
|
|
224
|
+
// for processing this job.
|
|
225
|
+
if (this.blockUntil) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Since there can be undefined jobs in the queue (when a job fails or queue is empty)
|
|
230
|
+
// we iterate until we find a job.
|
|
231
|
+
let job;
|
|
232
|
+
do {
|
|
233
|
+
job = await asyncFifoQueue.fetch();
|
|
234
|
+
} while (!job && asyncFifoQueue.numQueued() > 0);
|
|
235
|
+
if (job) {
|
|
236
|
+
const token = job.token;
|
|
237
|
+
asyncFifoQueue.add(this.retryIfFailed(() => this.processJob(job, token, () => asyncFifoQueue.numTotal() <= this._concurrency, jobsInProgress), this.opts.runRetryDelay));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
this.running = false;
|
|
241
|
+
return await asyncFifoQueue.waitAll();
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
this.running = false;
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns a promise that resolves to the next job in queue.
|
|
250
|
+
* @param token - worker token to be assigned to retrieved job
|
|
251
|
+
* @returns a Job or undefined if no job was available in the queue.
|
|
252
|
+
*/
|
|
253
|
+
async getNextJob(token, { block = true } = {}) {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
const nextJob = await this._getNextJob(await this.client, await this.blockingConnection.client, token, { block });
|
|
256
|
+
return this.trace(SpanKind.INTERNAL, 'getNextJob', this.name, async (span) => {
|
|
257
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
258
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
259
|
+
[TelemetryAttributes.QueueName]: this.name,
|
|
260
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
261
|
+
[TelemetryAttributes.WorkerOptions]: JSON.stringify({ block }),
|
|
262
|
+
[TelemetryAttributes.JobId]: nextJob === null || nextJob === void 0 ? void 0 : nextJob.id,
|
|
263
|
+
});
|
|
264
|
+
return nextJob;
|
|
265
|
+
}, (_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);
|
|
266
|
+
}
|
|
267
|
+
async _getNextJob(client, bclient, token, { block = true } = {}) {
|
|
268
|
+
var _a;
|
|
269
|
+
if (this.paused) {
|
|
270
|
+
if (block) {
|
|
271
|
+
await this.paused;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (this.closing) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (this.drained && block && !this.limitUntil && !this.waiting) {
|
|
281
|
+
this.waiting = this.waitForJob(bclient, this.blockUntil);
|
|
282
|
+
try {
|
|
283
|
+
this.blockUntil = await this.waiting;
|
|
284
|
+
if (this.blockUntil <= 0 || this.blockUntil - Date.now() < 1) {
|
|
285
|
+
return await this.moveToActive(client, token, this.opts.name);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
// Swallow error if locally not paused or not closing since we did not force a disconnection
|
|
290
|
+
if (!(this.paused || this.closing) &&
|
|
291
|
+
isNotConnectionError(err)) {
|
|
292
|
+
throw err;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
this.waiting = null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
const limitUntil = this.limitUntil;
|
|
301
|
+
if (limitUntil) {
|
|
302
|
+
(_a = this.abortDelayController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
303
|
+
this.abortDelayController = new AbortController();
|
|
304
|
+
await this.delay(this.getLimitUntil(limitUntil), this.abortDelayController);
|
|
305
|
+
}
|
|
306
|
+
return this.moveToActive(client, token, this.opts.name);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Overrides the rate limit to be active for the next jobs.
|
|
311
|
+
* @deprecated This method is deprecated and will be removed in v6. Use queue.rateLimit method instead.
|
|
312
|
+
* @param expireTimeMs - expire time in ms of this rate limit.
|
|
313
|
+
*/
|
|
314
|
+
async rateLimit(expireTimeMs) {
|
|
315
|
+
await this.trace(SpanKind.INTERNAL, 'rateLimit', this.name, async (span) => {
|
|
316
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
317
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
318
|
+
[TelemetryAttributes.WorkerRateLimit]: expireTimeMs,
|
|
319
|
+
});
|
|
320
|
+
await this.client.then(client => client.set(this.keys.limiter, Number.MAX_SAFE_INTEGER, 'PX', expireTimeMs));
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
get minimumBlockTimeout() {
|
|
324
|
+
return this.blockingConnection.capabilities.canBlockFor1Ms
|
|
325
|
+
? /* 1 millisecond is chosen because the granularity of our timestamps are milliseconds.
|
|
326
|
+
Obviously we can still process much faster than 1 job per millisecond but delays and rate limits
|
|
327
|
+
will never work with more accuracy than 1ms. */
|
|
328
|
+
0.001
|
|
329
|
+
: 0.002;
|
|
330
|
+
}
|
|
331
|
+
async moveToActive(client, token, name) {
|
|
332
|
+
const [jobData, id, limitUntil, delayUntil] = await this.scripts.moveToActive(client, token, name);
|
|
333
|
+
this.updateDelays(limitUntil, delayUntil);
|
|
334
|
+
return this.nextJobFromJobData(jobData, id, token);
|
|
335
|
+
}
|
|
336
|
+
async waitForJob(bclient, blockUntil) {
|
|
337
|
+
if (this.paused) {
|
|
338
|
+
return Infinity;
|
|
339
|
+
}
|
|
340
|
+
let timeout;
|
|
341
|
+
try {
|
|
342
|
+
if (!this.closing && !this.limitUntil) {
|
|
343
|
+
let blockTimeout = this.getBlockTimeout(blockUntil);
|
|
344
|
+
if (blockTimeout > 0) {
|
|
345
|
+
blockTimeout = this.blockingConnection.capabilities.canDoubleTimeout
|
|
346
|
+
? blockTimeout
|
|
347
|
+
: Math.ceil(blockTimeout);
|
|
348
|
+
// We cannot trust that the blocking connection stays blocking forever
|
|
349
|
+
// due to issues in Redis and IORedis, so we will reconnect if we
|
|
350
|
+
// don't get a response in the expected time.
|
|
351
|
+
timeout = setTimeout(async () => {
|
|
352
|
+
bclient.disconnect(!this.closing);
|
|
353
|
+
}, blockTimeout * 1000 + 1000);
|
|
354
|
+
this.updateDelays(); // reset delays to avoid reusing same values in next iteration
|
|
355
|
+
// Markers should only be used for un-blocking, so we will handle them in this
|
|
356
|
+
// function only.
|
|
357
|
+
const result = await bclient.bzpopmin(this.keys.marker, blockTimeout);
|
|
358
|
+
if (result) {
|
|
359
|
+
const [_key, member, score] = result;
|
|
360
|
+
if (member) {
|
|
361
|
+
return parseInt(score);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return 0;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
if (isNotConnectionError(error)) {
|
|
370
|
+
this.emit('error', error);
|
|
371
|
+
}
|
|
372
|
+
if (!this.closing) {
|
|
373
|
+
await this.delay();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
finally {
|
|
377
|
+
clearTimeout(timeout);
|
|
378
|
+
}
|
|
379
|
+
return Infinity;
|
|
380
|
+
}
|
|
381
|
+
getBlockTimeout(blockUntil) {
|
|
382
|
+
const opts = this.opts;
|
|
383
|
+
// when there are delayed jobs
|
|
384
|
+
if (blockUntil) {
|
|
385
|
+
const blockDelay = blockUntil - Date.now();
|
|
386
|
+
// when we reach the time to get new jobs
|
|
387
|
+
if (blockDelay <= 0) {
|
|
388
|
+
return blockDelay;
|
|
389
|
+
}
|
|
390
|
+
else if (blockDelay < this.minimumBlockTimeout * 1000) {
|
|
391
|
+
return this.minimumBlockTimeout;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
// We restrict the maximum block timeout to 10 second to avoid
|
|
395
|
+
// blocking the connection for too long in the case of reconnections
|
|
396
|
+
// reference: https://github.com/taskforcesh/bullmq/issues/1658
|
|
397
|
+
return Math.min(blockDelay / 1000, maximumBlockTimeout);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
return Math.max(opts.drainDelay, this.minimumBlockTimeout);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
getLimitUntil(limitUntil) {
|
|
405
|
+
// We restrict the maximum limit until to 30 second to
|
|
406
|
+
// be able to promote delayed jobs while queue is rate limited
|
|
407
|
+
return Math.min(limitUntil, maximumLimitUntil);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
*
|
|
411
|
+
* This function is exposed only for testing purposes.
|
|
412
|
+
*/
|
|
413
|
+
async delay(milliseconds, abortController) {
|
|
414
|
+
await delay(milliseconds || DELAY_TIME_1, abortController);
|
|
415
|
+
}
|
|
416
|
+
updateDelays(limitUntil = 0, delayUntil = 0) {
|
|
417
|
+
this.limitUntil = Math.max(limitUntil, 0) || 0;
|
|
418
|
+
this.blockUntil = Math.max(delayUntil, 0) || 0;
|
|
419
|
+
}
|
|
420
|
+
async nextJobFromJobData(jobData, jobId, token) {
|
|
421
|
+
if (!jobData) {
|
|
422
|
+
if (!this.drained) {
|
|
423
|
+
this.emit('drained');
|
|
424
|
+
this.drained = true;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
this.drained = false;
|
|
429
|
+
const job = this.createJob(jobData, jobId);
|
|
430
|
+
job.token = token;
|
|
431
|
+
// Add next scheduled job if necessary.
|
|
432
|
+
if (job.opts.repeat && !job.nextRepeatableJobId) {
|
|
433
|
+
// Use new job scheduler if possible
|
|
434
|
+
if (job.repeatJobKey) {
|
|
435
|
+
const jobScheduler = await this.jobScheduler;
|
|
436
|
+
await jobScheduler.upsertJobScheduler(job.repeatJobKey, job.opts.repeat, job.name, job.data, job.opts, { override: false, producerId: job.id });
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
const repeat = await this.repeat;
|
|
440
|
+
await repeat.updateRepeatableJob(job.name, job.data, job.opts, {
|
|
441
|
+
override: false,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return job;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
async processJob(job, token, fetchNextCallback = () => true, jobsInProgress) {
|
|
449
|
+
var _a, _b;
|
|
450
|
+
if (!job || this.closing || this.paused) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const srcPropagationMedatada = (_b = (_a = job.opts) === null || _a === void 0 ? void 0 : _a.telemetry) === null || _b === void 0 ? void 0 : _b.metadata;
|
|
454
|
+
return this.trace(SpanKind.CONSUMER, 'process', this.name, async (span) => {
|
|
455
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
456
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
457
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
458
|
+
[TelemetryAttributes.JobId]: job.id,
|
|
459
|
+
});
|
|
460
|
+
const handleCompleted = async (result) => {
|
|
461
|
+
jobsInProgress.delete(inProgressItem);
|
|
462
|
+
if (!this.connection.closing) {
|
|
463
|
+
const completed = await job.moveToCompleted(result, token, fetchNextCallback() && !(this.closing || this.paused));
|
|
464
|
+
this.emit('completed', job, result, 'active');
|
|
465
|
+
span === null || span === void 0 ? void 0 : span.addEvent('job completed', {
|
|
466
|
+
[TelemetryAttributes.JobResult]: JSON.stringify(result),
|
|
467
|
+
});
|
|
468
|
+
const [jobData, jobId, limitUntil, delayUntil] = completed || [];
|
|
469
|
+
this.updateDelays(limitUntil, delayUntil);
|
|
470
|
+
return this.nextJobFromJobData(jobData, jobId, token);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
const handleFailed = async (err) => {
|
|
474
|
+
jobsInProgress.delete(inProgressItem);
|
|
475
|
+
if (!this.connection.closing) {
|
|
476
|
+
try {
|
|
477
|
+
// Check if the job was manually rate-limited
|
|
478
|
+
if (err.message == RATE_LIMIT_ERROR) {
|
|
479
|
+
this.limitUntil = await this.moveLimitedBackToWait(job, token);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (err instanceof DelayedError ||
|
|
483
|
+
err.name == 'DelayedError' ||
|
|
484
|
+
err instanceof WaitingChildrenError ||
|
|
485
|
+
err.name == 'WaitingChildrenError') {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const result = await job.moveToFailed(err, token, true);
|
|
489
|
+
this.emit('failed', job, err, 'active');
|
|
490
|
+
span === null || span === void 0 ? void 0 : span.addEvent('job failed', {
|
|
491
|
+
[TelemetryAttributes.JobFailedReason]: err.message,
|
|
492
|
+
});
|
|
493
|
+
if (result) {
|
|
494
|
+
const [jobData, jobId, limitUntil, delayUntil] = result;
|
|
495
|
+
this.updateDelays(limitUntil, delayUntil);
|
|
496
|
+
return this.nextJobFromJobData(jobData, jobId, token);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
catch (err) {
|
|
500
|
+
this.emit('error', err);
|
|
501
|
+
// It probably means that the job has lost the lock before completion
|
|
502
|
+
// A worker will (or already has) moved the job back
|
|
503
|
+
// to the waiting list (as stalled)
|
|
504
|
+
span === null || span === void 0 ? void 0 : span.recordException(err.message);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
this.emit('active', job, 'waiting');
|
|
509
|
+
const processedOn = Date.now();
|
|
510
|
+
const inProgressItem = { job, ts: processedOn };
|
|
511
|
+
try {
|
|
512
|
+
jobsInProgress.add(inProgressItem);
|
|
513
|
+
const result = await this.callProcessJob(job, token);
|
|
514
|
+
return await handleCompleted(result);
|
|
515
|
+
}
|
|
516
|
+
catch (err) {
|
|
517
|
+
const failed = await handleFailed(err);
|
|
518
|
+
return failed;
|
|
519
|
+
}
|
|
520
|
+
finally {
|
|
521
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
522
|
+
[TelemetryAttributes.JobFinishedTimestamp]: Date.now(),
|
|
523
|
+
[TelemetryAttributes.JobProcessedTimestamp]: processedOn,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}, srcPropagationMedatada);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
*
|
|
530
|
+
* Pauses the processing of this queue only for this worker.
|
|
531
|
+
*/
|
|
532
|
+
async pause(doNotWaitActive) {
|
|
533
|
+
await this.trace(SpanKind.INTERNAL, 'pause', this.name, async (span) => {
|
|
534
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
535
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
536
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
537
|
+
[TelemetryAttributes.WorkerDoNotWaitActive]: doNotWaitActive,
|
|
538
|
+
});
|
|
539
|
+
if (!this.paused) {
|
|
540
|
+
this.paused = new Promise(resolve => {
|
|
541
|
+
this.resumeWorker = function () {
|
|
542
|
+
resolve();
|
|
543
|
+
this.paused = null; // Allow pause to be checked externally for paused state.
|
|
544
|
+
this.resumeWorker = null;
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
await (!doNotWaitActive && this.whenCurrentJobsFinished());
|
|
548
|
+
this.emit('paused');
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
*
|
|
554
|
+
* Resumes processing of this worker (if paused).
|
|
555
|
+
*/
|
|
556
|
+
resume() {
|
|
557
|
+
if (this.resumeWorker) {
|
|
558
|
+
this.trace(SpanKind.INTERNAL, 'resume', this.name, span => {
|
|
559
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
560
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
561
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
562
|
+
});
|
|
563
|
+
this.resumeWorker();
|
|
564
|
+
this.emit('resumed');
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
*
|
|
570
|
+
* Checks if worker is paused.
|
|
571
|
+
*
|
|
572
|
+
* @returns true if worker is paused, false otherwise.
|
|
573
|
+
*/
|
|
574
|
+
isPaused() {
|
|
575
|
+
return !!this.paused;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
*
|
|
579
|
+
* Checks if worker is currently running.
|
|
580
|
+
*
|
|
581
|
+
* @returns true if worker is running, false otherwise.
|
|
582
|
+
*/
|
|
583
|
+
isRunning() {
|
|
584
|
+
return this.running;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
*
|
|
588
|
+
* Closes the worker and related redis connections.
|
|
589
|
+
*
|
|
590
|
+
* This method waits for current jobs to finalize before returning.
|
|
591
|
+
*
|
|
592
|
+
* @param force - Use force boolean parameter if you do not want to wait for
|
|
593
|
+
* current jobs to be processed. When using telemetry, be mindful that it can
|
|
594
|
+
* interfere with the proper closure of spans, potentially preventing them from being exported.
|
|
595
|
+
*
|
|
596
|
+
* @returns Promise that resolves when the worker has been closed.
|
|
597
|
+
*/
|
|
598
|
+
async close(force = false) {
|
|
599
|
+
if (this.closing) {
|
|
600
|
+
return this.closing;
|
|
601
|
+
}
|
|
602
|
+
await this.trace(SpanKind.INTERNAL, 'close', this.name, async (span) => {
|
|
603
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
604
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
605
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
606
|
+
[TelemetryAttributes.WorkerForceClose]: force,
|
|
607
|
+
});
|
|
608
|
+
this.closing = (async () => {
|
|
609
|
+
var _a, _b;
|
|
610
|
+
this.emit('closing', 'closing queue');
|
|
611
|
+
(_a = this.abortDelayController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
612
|
+
this.resume();
|
|
613
|
+
// Define the async cleanup functions
|
|
614
|
+
const asyncCleanups = [
|
|
615
|
+
() => {
|
|
616
|
+
return force || this.whenCurrentJobsFinished(false);
|
|
617
|
+
},
|
|
618
|
+
() => { var _a; return (_a = this.childPool) === null || _a === void 0 ? void 0 : _a.clean(); },
|
|
619
|
+
() => this.blockingConnection.close(force),
|
|
620
|
+
() => this.connection.close(force),
|
|
621
|
+
];
|
|
622
|
+
// Run cleanup functions sequentially and make sure all are run despite any errors
|
|
623
|
+
for (const cleanup of asyncCleanups) {
|
|
624
|
+
try {
|
|
625
|
+
await cleanup();
|
|
626
|
+
}
|
|
627
|
+
catch (err) {
|
|
628
|
+
this.emit('error', err);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
clearTimeout(this.extendLocksTimer);
|
|
632
|
+
(_b = this.stalledCheckStopper) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
633
|
+
this.closed = true;
|
|
634
|
+
this.emit('closed');
|
|
635
|
+
})();
|
|
636
|
+
return await this.closing;
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
*
|
|
641
|
+
* Manually starts the stalled checker.
|
|
642
|
+
* The check will run once as soon as this method is called, and
|
|
643
|
+
* then every opts.stalledInterval milliseconds until the worker is closed.
|
|
644
|
+
* Note: Normally you do not need to call this method, since the stalled checker
|
|
645
|
+
* is automatically started when the worker starts processing jobs after
|
|
646
|
+
* calling run. However if you want to process the jobs manually you need
|
|
647
|
+
* to call this method to start the stalled checker.
|
|
648
|
+
*
|
|
649
|
+
* @see {@link https://docs.bullmq.io/patterns/manually-fetching-jobs}
|
|
650
|
+
*/
|
|
651
|
+
async startStalledCheckTimer() {
|
|
652
|
+
if (!this.opts.skipStalledCheck) {
|
|
653
|
+
if (!this.closing) {
|
|
654
|
+
await this.trace(SpanKind.INTERNAL, 'startStalledCheckTimer', this.name, async (span) => {
|
|
655
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
656
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
657
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
658
|
+
});
|
|
659
|
+
this.stalledChecker().catch(err => {
|
|
660
|
+
this.emit('error', err);
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
async stalledChecker() {
|
|
667
|
+
while (!this.closing) {
|
|
668
|
+
try {
|
|
669
|
+
await this.checkConnectionError(() => this.moveStalledJobsToWait());
|
|
670
|
+
}
|
|
671
|
+
catch (err) {
|
|
672
|
+
this.emit('error', err);
|
|
673
|
+
}
|
|
674
|
+
await new Promise(resolve => {
|
|
675
|
+
const timeout = setTimeout(resolve, this.opts.stalledInterval);
|
|
676
|
+
this.stalledCheckStopper = () => {
|
|
677
|
+
clearTimeout(timeout);
|
|
678
|
+
resolve();
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
startLockExtenderTimer(jobsInProgress) {
|
|
684
|
+
if (!this.opts.skipLockRenewal) {
|
|
685
|
+
clearTimeout(this.extendLocksTimer);
|
|
686
|
+
if (!this.closed) {
|
|
687
|
+
this.extendLocksTimer = setTimeout(async () => {
|
|
688
|
+
// Get all the jobs whose locks expire in less than 1/2 of the lockRenewTime
|
|
689
|
+
const now = Date.now();
|
|
690
|
+
const jobsToExtend = [];
|
|
691
|
+
for (const item of jobsInProgress) {
|
|
692
|
+
const { job, ts } = item;
|
|
693
|
+
if (!ts) {
|
|
694
|
+
item.ts = now;
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
if (ts + this.opts.lockRenewTime / 2 < now) {
|
|
698
|
+
item.ts = now;
|
|
699
|
+
jobsToExtend.push(job);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
if (jobsToExtend.length) {
|
|
704
|
+
await this.extendLocks(jobsToExtend);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
catch (err) {
|
|
708
|
+
this.emit('error', err);
|
|
709
|
+
}
|
|
710
|
+
this.startLockExtenderTimer(jobsInProgress);
|
|
711
|
+
}, this.opts.lockRenewTime / 2);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Returns a promise that resolves when active jobs are cleared
|
|
717
|
+
*
|
|
718
|
+
* @returns
|
|
719
|
+
*/
|
|
720
|
+
async whenCurrentJobsFinished(reconnect = true) {
|
|
721
|
+
//
|
|
722
|
+
// Force reconnection of blocking connection to abort blocking redis call immediately.
|
|
723
|
+
//
|
|
724
|
+
if (this.waiting) {
|
|
725
|
+
// If we are not going to reconnect, we will not wait for the disconnection.
|
|
726
|
+
await this.blockingConnection.disconnect(reconnect);
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
reconnect = false;
|
|
730
|
+
}
|
|
731
|
+
if (this.asyncFifoQueue) {
|
|
732
|
+
await this.asyncFifoQueue.waitAll();
|
|
733
|
+
}
|
|
734
|
+
reconnect && (await this.blockingConnection.reconnect());
|
|
735
|
+
}
|
|
736
|
+
async retryIfFailed(fn, delayInMs) {
|
|
737
|
+
const retry = 1;
|
|
738
|
+
do {
|
|
739
|
+
try {
|
|
740
|
+
return await fn();
|
|
741
|
+
}
|
|
742
|
+
catch (err) {
|
|
743
|
+
this.emit('error', err);
|
|
744
|
+
if (delayInMs) {
|
|
745
|
+
await this.delay(delayInMs);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
} while (retry);
|
|
752
|
+
}
|
|
753
|
+
async extendLocks(jobs) {
|
|
754
|
+
await this.trace(SpanKind.INTERNAL, 'extendLocks', this.name, async (span) => {
|
|
755
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
756
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
757
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
758
|
+
[TelemetryAttributes.WorkerJobsToExtendLocks]: jobs.map(job => job.id),
|
|
759
|
+
});
|
|
760
|
+
try {
|
|
761
|
+
const erroredJobIds = await this.scripts.extendLocks(jobs.map(job => job.id), jobs.map(job => job.token), this.opts.lockDuration);
|
|
762
|
+
for (const jobId of erroredJobIds) {
|
|
763
|
+
// TODO: Send signal to process function that the job has been lost.
|
|
764
|
+
this.emit('error', new Error(`could not renew lock for job ${jobId}`));
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
catch (err) {
|
|
768
|
+
this.emit('error', err);
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
async moveStalledJobsToWait() {
|
|
773
|
+
await this.trace(SpanKind.INTERNAL, 'moveStalledJobsToWait', this.name, async (span) => {
|
|
774
|
+
const chunkSize = 50;
|
|
775
|
+
const [failed, stalled] = await this.scripts.moveStalledJobsToWait();
|
|
776
|
+
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
777
|
+
[TelemetryAttributes.WorkerId]: this.id,
|
|
778
|
+
[TelemetryAttributes.WorkerName]: this.opts.name,
|
|
779
|
+
[TelemetryAttributes.WorkerStalledJobs]: stalled,
|
|
780
|
+
[TelemetryAttributes.WorkerFailedJobs]: failed,
|
|
781
|
+
});
|
|
782
|
+
stalled.forEach((jobId) => {
|
|
783
|
+
span === null || span === void 0 ? void 0 : span.addEvent('job stalled', {
|
|
784
|
+
[TelemetryAttributes.JobId]: jobId,
|
|
785
|
+
});
|
|
786
|
+
this.emit('stalled', jobId, 'active');
|
|
787
|
+
});
|
|
788
|
+
// Todo: check if there any listeners on failed event
|
|
789
|
+
const jobPromises = [];
|
|
790
|
+
for (let i = 0; i < failed.length; i++) {
|
|
791
|
+
jobPromises.push(Job.fromId(this, failed[i]));
|
|
792
|
+
if ((i + 1) % chunkSize === 0) {
|
|
793
|
+
this.notifyFailedJobs(await Promise.all(jobPromises));
|
|
794
|
+
jobPromises.length = 0;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
this.notifyFailedJobs(await Promise.all(jobPromises));
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
notifyFailedJobs(failedJobs, span) {
|
|
801
|
+
const failedReason = 'job stalled more than allowable limit';
|
|
802
|
+
failedJobs.forEach((job) => {
|
|
803
|
+
span === null || span === void 0 ? void 0 : span.addEvent('job failed', {
|
|
804
|
+
[TelemetryAttributes.JobId]: job.id,
|
|
805
|
+
[TelemetryAttributes.JobName]: job.name,
|
|
806
|
+
[TelemetryAttributes.JobFailedReason]: failedReason,
|
|
807
|
+
});
|
|
808
|
+
this.emit('failed', job, new Error(failedReason), 'active');
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
moveLimitedBackToWait(job, token) {
|
|
812
|
+
return this.scripts.moveJobFromActiveToWait(job.id, token);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
//# sourceMappingURL=worker.js.map
|