bunqueue-client 0.1.9 → 0.2.1
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/CHANGELOG.md +165 -0
- package/LEGACY.md +460 -0
- package/README.md +204 -349
- package/dist/ack-batcher.js +7 -67
- package/dist/canonical-manifest.json +934 -0
- package/dist/chunk-b967v3w3.js +79 -0
- package/dist/chunk-fekm0ma6.js +110 -0
- package/dist/chunk-jxkszwqp.js +573 -0
- package/dist/embedded.js +16510 -0
- package/dist/frame.js +14 -57
- package/dist/index.d.ts +1 -27
- package/dist/index.js +10953 -16
- package/dist/legacy.d.ts +1 -0
- package/dist/legacy.js +2081 -0
- package/dist/{ack-batcher.d.ts → types/sdk/typescript/src/ack-batcher.d.ts} +3 -3
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/aging.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/batch.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue-api.d.ts +5 -5
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue.d.ts +13 -13
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/circuit-breaker.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dedup-debounce.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dlq-rate-limit.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/rate-gate.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/retry.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/triggers.d.ts +3 -3
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/ttl.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/types.d.ts +4 -4
- package/dist/types/sdk/typescript/src/canonical-transport/bun-sqlite-types.d.ts +21 -0
- package/dist/{connection-pool.d.ts → types/sdk/typescript/src/connection-pool.d.ts} +1 -1
- package/dist/{connection-types.d.ts → types/sdk/typescript/src/connection-types.d.ts} +1 -1
- package/dist/{connection.d.ts → types/sdk/typescript/src/connection.d.ts} +6 -19
- package/dist/{errors.d.ts → types/sdk/typescript/src/errors.d.ts} +3 -0
- package/dist/types/sdk/typescript/src/flow-commit.d.ts +5 -0
- package/dist/types/sdk/typescript/src/flow-plan-legacy.d.ts +13 -0
- package/dist/types/sdk/typescript/src/flow-plan.d.ts +29 -0
- package/dist/{flow-types.d.ts → types/sdk/typescript/src/flow-types.d.ts} +7 -4
- package/dist/{flow.d.ts → types/sdk/typescript/src/flow.d.ts} +6 -10
- package/dist/{frame.d.ts → types/sdk/typescript/src/frame.d.ts} +1 -1
- package/dist/types/sdk/typescript/src/index.d.ts +10 -0
- package/dist/{job.d.ts → types/sdk/typescript/src/job.d.ts} +4 -3
- package/dist/types/sdk/typescript/src/legacy.d.ts +27 -0
- package/dist/{observability.d.ts → types/sdk/typescript/src/observability.d.ts} +14 -0
- package/dist/{queue-admin.d.ts → types/sdk/typescript/src/queue-admin.d.ts} +3 -4
- package/dist/{queue-control.d.ts → types/sdk/typescript/src/queue-control.d.ts} +5 -5
- package/dist/{queue-query.d.ts → types/sdk/typescript/src/queue-query.d.ts} +3 -3
- package/dist/{queue.d.ts → types/sdk/typescript/src/queue.d.ts} +8 -8
- package/dist/{responses.d.ts → types/sdk/typescript/src/responses.d.ts} +2 -2
- package/dist/types/sdk/typescript/src/serialization.d.ts +10 -0
- package/dist/{socket-factory.d.ts → types/sdk/typescript/src/socket-factory.d.ts} +1 -1
- package/dist/types/sdk/typescript/src/terminal-outcome.d.ts +8 -0
- package/dist/{types.d.ts → types/sdk/typescript/src/types.d.ts} +5 -2
- package/dist/{worker-base.d.ts → types/sdk/typescript/src/worker-base.d.ts} +6 -6
- package/dist/types/sdk/typescript/src/worker-slot-signal.d.ts +6 -0
- package/dist/{worker-types.d.ts → types/sdk/typescript/src/worker-types.d.ts} +3 -3
- package/dist/{worker.d.ts → types/sdk/typescript/src/worker.d.ts} +3 -2
- package/dist/types/src/application/background/dlq.d.ts +2 -0
- package/dist/types/src/application/background/lifecycle.d.ts +4 -0
- package/dist/types/src/application/background/recovery/active.d.ts +5 -0
- package/dist/types/src/application/background/recovery/index.d.ts +2 -0
- package/dist/types/src/application/background/recovery/pending.d.ts +3 -0
- package/dist/types/src/application/background/recovery/restore.d.ts +5 -0
- package/dist/types/src/application/background/recovery/shared.d.ts +6 -0
- package/dist/types/src/application/background/timeouts.d.ts +25 -0
- package/dist/types/src/application/backgroundTasks.d.ts +7 -0
- package/dist/types/src/application/cleanupTasks.d.ts +10 -0
- package/dist/types/src/application/clientOwnership.d.ts +65 -0
- package/dist/types/src/application/clientTracking.d.ts +40 -0
- package/dist/types/src/application/completedCleanup.d.ts +34 -0
- package/dist/types/src/application/completedRetry.d.ts +21 -0
- package/dist/types/src/application/contextFactory.d.ts +49 -0
- package/dist/types/src/application/dependencyCompletions.d.ts +63 -0
- package/dist/types/src/application/dependencyProcessor.d.ts +15 -0
- package/dist/types/src/application/dependencyResultTracker.d.ts +18 -0
- package/dist/types/src/application/dlqManager.d.ts +49 -0
- package/dist/types/src/application/dlqRetry.d.ts +12 -0
- package/dist/types/src/application/emptyQueueCleanup.d.ts +3 -0
- package/dist/types/src/application/eventsManager.d.ts +50 -0
- package/dist/types/src/application/flowFailureRecovery.d.ts +20 -0
- package/dist/types/src/application/flowParentBackpatch.d.ts +27 -0
- package/dist/types/src/application/jobLogsManager.d.ts +21 -0
- package/dist/types/src/application/latencyTracker.d.ts +39 -0
- package/dist/types/src/application/lockManager.d.ts +15 -0
- package/dist/types/src/application/lockOperations.d.ts +38 -0
- package/dist/types/src/application/metricsExporter.d.ts +27 -0
- package/dist/types/src/application/monitoringChecks.d.ts +36 -0
- package/dist/types/src/application/operations/ack/batch.d.ts +8 -0
- package/dist/types/src/application/operations/ack/completion.d.ts +3 -0
- package/dist/types/src/application/operations/ack/failure.d.ts +3 -0
- package/dist/types/src/application/operations/ack.d.ts +5 -0
- package/dist/types/src/application/operations/ackHelpers.d.ts +36 -0
- package/dist/types/src/application/operations/customId.d.ts +51 -0
- package/dist/types/src/application/operations/flowPush.d.ts +9 -0
- package/dist/types/src/application/operations/flowTopologyValidation.d.ts +3 -0
- package/dist/types/src/application/operations/flowValidation.d.ts +3 -0
- package/dist/types/src/application/operations/jobClaim.d.ts +17 -0
- package/dist/types/src/application/operations/jobManagement.d.ts +45 -0
- package/dist/types/src/application/operations/jobMoveOperations.d.ts +9 -0
- package/dist/types/src/application/operations/jobPromotion.d.ts +7 -0
- package/dist/types/src/application/operations/jobStateTransitions.d.ts +15 -0
- package/dist/types/src/application/operations/parentLink.d.ts +36 -0
- package/dist/types/src/application/operations/parentLinkInput.d.ts +8 -0
- package/dist/types/src/application/operations/pull.d.ts +20 -0
- package/dist/types/src/application/operations/pullFinalization.d.ts +6 -0
- package/dist/types/src/application/operations/pullStateTransition.d.ts +51 -0
- package/dist/types/src/application/operations/push.d.ts +13 -0
- package/dist/types/src/application/operations/pushAdmission.d.ts +36 -0
- package/dist/types/src/application/operations/pushBatch.d.ts +4 -0
- package/dist/types/src/application/operations/pushContext.d.ts +48 -0
- package/dist/types/src/application/operations/pushDeduplication.d.ts +42 -0
- package/dist/types/src/application/operations/pushInsert.d.ts +39 -0
- package/dist/types/src/application/operations/pushLocks.d.ts +15 -0
- package/dist/types/src/application/operations/query/collect.d.ts +12 -0
- package/dist/types/src/application/operations/query/jobLookup.d.ts +9 -0
- package/dist/types/src/application/operations/query/pagination.d.ts +8 -0
- package/dist/types/src/application/operations/query/state.d.ts +4 -0
- package/dist/types/src/application/operations/queryOperations.d.ts +5 -0
- package/dist/types/src/application/operations/queueControl.d.ts +50 -0
- package/dist/types/src/application/orphanRecovery.d.ts +25 -0
- package/dist/types/src/application/prometheusOperationalMetrics.d.ts +31 -0
- package/dist/types/src/application/queue-manager/ack.d.ts +23 -0
- package/dist/types/src/application/queue-manager/configuration.d.ts +27 -0
- package/dist/types/src/application/queue-manager/context.d.ts +5 -0
- package/dist/types/src/application/queue-manager/control.d.ts +20 -0
- package/dist/types/src/application/queue-manager/delivery.d.ts +33 -0
- package/dist/types/src/application/queue-manager/dependencies.d.ts +8 -0
- package/dist/types/src/application/queue-manager/dependency-runtime.d.ts +8 -0
- package/dist/types/src/application/queue-manager/flow-failures.d.ts +18 -0
- package/dist/types/src/application/queue-manager/flow-options.d.ts +8 -0
- package/dist/types/src/application/queue-manager/job-management.d.ts +17 -0
- package/dist/types/src/application/queue-manager/lifecycle.d.ts +4 -0
- package/dist/types/src/application/queue-manager/limits.d.ts +58 -0
- package/dist/types/src/application/queue-manager/locks.d.ts +21 -0
- package/dist/types/src/application/queue-manager/observability.d.ts +16 -0
- package/dist/types/src/application/queue-manager/queries.d.ts +24 -0
- package/dist/types/src/application/queue-manager/repeat.d.ts +4 -0
- package/dist/types/src/application/queue-manager/services.d.ts +19 -0
- package/dist/types/src/application/queue-manager/state.d.ts +98 -0
- package/dist/types/src/application/queue-manager/stats.d.ts +28 -0
- package/dist/types/src/application/queueManager.d.ts +5 -0
- package/dist/types/src/application/queueStatsAggregator.d.ts +23 -0
- package/dist/types/src/application/queueTelemetryJournal.d.ts +24 -0
- package/dist/types/src/application/repeatJobs.d.ts +7 -0
- package/dist/types/src/application/stallDetection.d.ts +26 -0
- package/dist/types/src/application/statsManager.d.ts +59 -0
- package/dist/types/src/application/taskErrorTracking.d.ts +22 -0
- package/dist/types/src/application/throughputTracker.d.ts +34 -0
- package/dist/types/src/application/types/ack.d.ts +136 -0
- package/dist/types/src/application/types/background.d.ts +18 -0
- package/dist/types/src/application/types/config.d.ts +41 -0
- package/dist/types/src/application/types/contextFactory.d.ts +89 -0
- package/dist/types/src/application/types/contexts.d.ts +117 -0
- package/dist/types/src/application/types/index.d.ts +7 -0
- package/dist/types/src/application/types/query.d.ts +23 -0
- package/dist/types/src/application/types/queueManager.d.ts +100 -0
- package/dist/types/src/application/webhookManager.d.ts +47 -0
- package/dist/types/src/application/workerManager.d.ts +61 -0
- package/dist/types/src/client/bunqueue/aging.d.ts +16 -0
- package/dist/types/src/client/bunqueue/batch.d.ts +16 -0
- package/dist/types/src/client/bunqueue/cancellation.d.ts +21 -0
- package/dist/types/src/client/bunqueue/circuitBreaker.d.ts +21 -0
- package/dist/types/src/client/bunqueue/dedupDebounce.d.ts +12 -0
- package/dist/types/src/client/bunqueue/dlqRateLimit.d.ts +26 -0
- package/dist/types/src/client/bunqueue/retry.d.ts +8 -0
- package/dist/types/src/client/bunqueue/runtime.d.ts +35 -0
- package/dist/types/src/client/bunqueue/triggers.d.ts +17 -0
- package/dist/types/src/client/bunqueue/ttl.d.ts +17 -0
- package/dist/types/src/client/bunqueue/types.d.ts +147 -0
- package/dist/types/src/client/bunqueue.d.ts +73 -0
- package/dist/types/src/client/dlqConversion.d.ts +5 -0
- package/dist/types/src/client/errors.d.ts +24 -0
- package/dist/types/src/client/events.d.ts +85 -0
- package/dist/types/src/client/flow.d.ts +70 -0
- package/dist/types/src/client/flowAtomic.d.ts +9 -0
- package/dist/types/src/client/flowJobCoreMethods.d.ts +28 -0
- package/dist/types/src/client/flowJobDependencies.d.ts +7 -0
- package/dist/types/src/client/flowJobFactory.d.ts +24 -0
- package/dist/types/src/client/flowJobMoveMethods.d.ts +16 -0
- package/dist/types/src/client/flowJobTypes.d.ts +29 -0
- package/dist/types/src/client/flowLegacyPlan.d.ts +16 -0
- package/dist/types/src/client/flowOptions.d.ts +10 -0
- package/dist/types/src/client/flowPlan.d.ts +16 -0
- package/dist/types/src/client/flowPush.d.ts +27 -0
- package/dist/types/src/client/flowReader.d.ts +10 -0
- package/dist/types/src/client/flowResults.d.ts +11 -0
- package/dist/types/src/client/flowTypes.d.ts +77 -0
- package/dist/types/src/client/forwarder.d.ts +75 -0
- package/dist/types/src/client/groupId.d.ts +1 -0
- package/dist/types/src/client/index.d.ts +46 -0
- package/dist/types/src/client/jobConversion.d.ts +10 -0
- package/dist/types/src/client/jobConversionHelpers.d.ts +28 -0
- package/dist/types/src/client/jobConversionTypes.d.ts +88 -0
- package/dist/types/src/client/jobDeduplication.d.ts +6 -0
- package/dist/types/src/client/jobHelpers.d.ts +31 -0
- package/dist/types/src/client/legacyConnectionOptions.d.ts +8 -0
- package/dist/types/src/client/manager.d.ts +15 -0
- package/dist/types/src/client/pro.d.ts +9 -0
- package/dist/types/src/client/queue/addBatcher.d.ts +59 -0
- package/dist/types/src/client/queue/bullmqCompat.d.ts +57 -0
- package/dist/types/src/client/queue/deduplication.d.ts +14 -0
- package/dist/types/src/client/queue/dlq.d.ts +61 -0
- package/dist/types/src/client/queue/dlqJobMethods.d.ts +9 -0
- package/dist/types/src/client/queue/dlqOps.d.ts +26 -0
- package/dist/types/src/client/queue/dlqStats.d.ts +3 -0
- package/dist/types/src/client/queue/failWire.d.ts +17 -0
- package/dist/types/src/client/queue/helpers.d.ts +19 -0
- package/dist/types/src/client/queue/job-proxy/dependencies.d.ts +9 -0
- package/dist/types/src/client/queue/job-proxy/reflection.d.ts +2 -0
- package/dist/types/src/client/queue/job-proxy/simple.d.ts +3 -0
- package/dist/types/src/client/queue/job-proxy/tcp.d.ts +4 -0
- package/dist/types/src/client/queue/jobMetadata.d.ts +10 -0
- package/dist/types/src/client/queue/jobMove.d.ts +32 -0
- package/dist/types/src/client/queue/jobProxy.d.ts +4 -0
- package/dist/types/src/client/queue/operations/add/bulk.d.ts +7 -0
- package/dist/types/src/client/queue/operations/add/payload.d.ts +25 -0
- package/dist/types/src/client/queue/operations/add/single.d.ts +3 -0
- package/dist/types/src/client/queue/operations/add.d.ts +2 -0
- package/dist/types/src/client/queue/operations/control.d.ts +42 -0
- package/dist/types/src/client/queue/operations/counts.d.ts +48 -0
- package/dist/types/src/client/queue/operations/groups.d.ts +24 -0
- package/dist/types/src/client/queue/operations/management.d.ts +51 -0
- package/dist/types/src/client/queue/operations/query.d.ts +50 -0
- package/dist/types/src/client/queue/operations/queryStates.d.ts +13 -0
- package/dist/types/src/client/queue/operations/queryTcpPages.d.ts +14 -0
- package/dist/types/src/client/queue/queue.d.ts +12 -0
- package/dist/types/src/client/queue/rateLimit.d.ts +46 -0
- package/dist/types/src/client/queue/runtime/compatibility.d.ts +13 -0
- package/dist/types/src/client/queue/runtime/configuration.d.ts +46 -0
- package/dist/types/src/client/queue/runtime/connection.d.ts +6 -0
- package/dist/types/src/client/queue/runtime/control.d.ts +41 -0
- package/dist/types/src/client/queue/runtime/queries.d.ts +66 -0
- package/dist/types/src/client/queue/runtime/scheduling.d.ts +33 -0
- package/dist/types/src/client/queue/runtime/state.d.ts +101 -0
- package/dist/types/src/client/queue/scheduler.d.ts +58 -0
- package/dist/types/src/client/queue/schedulerPagination.d.ts +7 -0
- package/dist/types/src/client/queue/stall.d.ts +20 -0
- package/dist/types/src/client/queue/types/add.d.ts +40 -0
- package/dist/types/src/client/queue/types/contexts.d.ts +33 -0
- package/dist/types/src/client/queue/types/index.d.ts +3 -0
- package/dist/types/src/client/queue/types/job.d.ts +50 -0
- package/dist/types/src/client/queue/types/runtime.d.ts +35 -0
- package/dist/types/src/client/queue/workers.d.ts +36 -0
- package/dist/types/src/client/queue-events/tcpSubscription.d.ts +23 -0
- package/dist/types/src/client/queue.d.ts +5 -0
- package/dist/types/src/client/queueGroup.d.ts +51 -0
- package/dist/types/src/client/resolveToken.d.ts +10 -0
- package/dist/types/src/client/sandboxed/index.d.ts +7 -0
- package/dist/types/src/client/sandboxed/queueOps.d.ts +24 -0
- package/dist/types/src/client/sandboxed/runtime/dispatch.d.ts +13 -0
- package/dist/types/src/client/sandboxed/runtime/lifecycle.d.ts +20 -0
- package/dist/types/src/client/sandboxed/runtime/log.d.ts +1 -0
- package/dist/types/src/client/sandboxed/runtime/pool.d.ts +11 -0
- package/dist/types/src/client/sandboxed/runtime/recovery.d.ts +11 -0
- package/dist/types/src/client/sandboxed/runtime/state.d.ts +39 -0
- package/dist/types/src/client/sandboxed/types/index.d.ts +2 -0
- package/dist/types/src/client/sandboxed/types/options.d.ts +27 -0
- package/dist/types/src/client/sandboxed/types/process.d.ts +39 -0
- package/dist/types/src/client/sandboxed/worker.d.ts +4 -0
- package/dist/types/src/client/sandboxed/wrapper.d.ts +12 -0
- package/dist/types/src/client/sandboxedWorker.d.ts +6 -0
- package/dist/types/src/client/tcp/client.d.ts +6 -0
- package/dist/types/src/client/tcp/commandQueue.d.ts +23 -0
- package/dist/types/src/client/tcp/connection.d.ts +4 -0
- package/dist/types/src/client/tcp/errors.d.ts +6 -0
- package/dist/types/src/client/tcp/health.d.ts +60 -0
- package/dist/types/src/client/tcp/index.d.ts +11 -0
- package/dist/types/src/client/tcp/reconnect.d.ts +47 -0
- package/dist/types/src/client/tcp/runtime/commands.d.ts +9 -0
- package/dist/types/src/client/tcp/runtime/connectivity.d.ts +13 -0
- package/dist/types/src/client/tcp/runtime/health.d.ts +14 -0
- package/dist/types/src/client/tcp/runtime/lifecycle.d.ts +8 -0
- package/dist/types/src/client/tcp/runtime/state.d.ts +50 -0
- package/dist/types/src/client/tcp/shared.d.ts +12 -0
- package/dist/types/src/client/tcp/transport.d.ts +18 -0
- package/dist/types/src/client/tcp/types/command.d.ts +9 -0
- package/dist/types/src/client/tcp/types/connection.d.ts +31 -0
- package/dist/types/src/client/tcp/types/index.d.ts +5 -0
- package/dist/types/src/client/tcp/types/socket.d.ts +8 -0
- package/dist/types/src/client/tcp/types/tls.d.ts +4 -0
- package/dist/types/src/client/tcp/types.d.ts +2 -0
- package/dist/types/src/client/tcpClient.d.ts +6 -0
- package/dist/types/src/client/tcpPool.d.ts +69 -0
- package/dist/types/src/client/types/connection.d.ts +30 -0
- package/dist/types/src/client/types/dlq.d.ts +45 -0
- package/dist/types/src/client/types/events.d.ts +54 -0
- package/dist/types/src/client/types/flow.d.ts +22 -0
- package/dist/types/src/client/types/index.d.ts +10 -0
- package/dist/types/src/client/types/job.d.ts +131 -0
- package/dist/types/src/client/types/metrics.d.ts +1 -0
- package/dist/types/src/client/types/options.d.ts +72 -0
- package/dist/types/src/client/types/worker.d.ts +54 -0
- package/dist/types/src/client/types.d.ts +2 -0
- package/dist/types/src/client/worker/ackBatcher.d.ts +55 -0
- package/dist/types/src/client/worker/ackFrontier.d.ts +21 -0
- package/dist/types/src/client/worker/ackOutcome.d.ts +8 -0
- package/dist/types/src/client/worker/batchExecution.d.ts +14 -0
- package/dist/types/src/client/worker/constants.d.ts +7 -0
- package/dist/types/src/client/worker/groupConcurrency.d.ts +49 -0
- package/dist/types/src/client/worker/handlers/completion.d.ts +29 -0
- package/dist/types/src/client/worker/handlers/dependencies.d.ts +11 -0
- package/dist/types/src/client/worker/handlers/mutations.d.ts +23 -0
- package/dist/types/src/client/worker/handlers/queries.d.ts +15 -0
- package/dist/types/src/client/worker/jobParser.d.ts +9 -0
- package/dist/types/src/client/worker/processor.d.ts +11 -0
- package/dist/types/src/client/worker/processorHandlers.d.ts +4 -0
- package/dist/types/src/client/worker/processorOutcome.d.ts +14 -0
- package/dist/types/src/client/worker/processorResult.d.ts +2 -0
- package/dist/types/src/client/worker/runtime/buffer.d.ts +8 -0
- package/dist/types/src/client/worker/runtime/control.d.ts +28 -0
- package/dist/types/src/client/worker/runtime/execution.d.ts +16 -0
- package/dist/types/src/client/worker/runtime/lifecycle.d.ts +7 -0
- package/dist/types/src/client/worker/runtime/manual.d.ts +10 -0
- package/dist/types/src/client/worker/runtime/options.d.ts +5 -0
- package/dist/types/src/client/worker/runtime/polling.d.ts +14 -0
- package/dist/types/src/client/worker/runtime/state.d.ts +121 -0
- package/dist/types/src/client/worker/types/index.d.ts +5 -0
- package/dist/types/src/client/worker/types/manual.d.ts +7 -0
- package/dist/types/src/client/worker/types/options.d.ts +26 -0
- package/dist/types/src/client/worker/types/outcome.d.ts +23 -0
- package/dist/types/src/client/worker/types/processor.d.ts +25 -0
- package/dist/types/src/client/worker/types/transport.d.ts +11 -0
- package/dist/types/src/client/worker/worker.d.ts +6 -0
- package/dist/types/src/client/worker/workerHeartbeat.d.ts +15 -0
- package/dist/types/src/client/worker/workerPull.d.ts +24 -0
- package/dist/types/src/client/worker/workerRateLimiter.d.ts +51 -0
- package/dist/types/src/client/worker.d.ts +6 -0
- package/dist/types/src/client/workflow/admission.d.ts +45 -0
- package/dist/types/src/client/workflow/clock.d.ts +60 -0
- package/dist/types/src/client/workflow/compensationChild.d.ts +33 -0
- package/dist/types/src/client/workflow/compensationClaim.d.ts +11 -0
- package/dist/types/src/client/workflow/compensationPass.d.ts +17 -0
- package/dist/types/src/client/workflow/compensationSupport.d.ts +24 -0
- package/dist/types/src/client/workflow/compensator.d.ts +34 -0
- package/dist/types/src/client/workflow/definitionGuard.d.ts +11 -0
- package/dist/types/src/client/workflow/emitter.d.ts +17 -0
- package/dist/types/src/client/workflow/engine.d.ts +66 -0
- package/dist/types/src/client/workflow/eventTypes.d.ts +44 -0
- package/dist/types/src/client/workflow/executionFence.d.ts +15 -0
- package/dist/types/src/client/workflow/executionTypes.d.ts +133 -0
- package/dist/types/src/client/workflow/executor.d.ts +52 -0
- package/dist/types/src/client/workflow/executorLifecycle.d.ts +19 -0
- package/dist/types/src/client/workflow/executorNodes.d.ts +18 -0
- package/dist/types/src/client/workflow/executorQueue.d.ts +9 -0
- package/dist/types/src/client/workflow/forEachRunner.d.ts +4 -0
- package/dist/types/src/client/workflow/identity.d.ts +48 -0
- package/dist/types/src/client/workflow/index.d.ts +23 -0
- package/dist/types/src/client/workflow/loops.d.ts +11 -0
- package/dist/types/src/client/workflow/mapRunner.d.ts +4 -0
- package/dist/types/src/client/workflow/recovery.d.ts +32 -0
- package/dist/types/src/client/workflow/rollbackControl.d.ts +37 -0
- package/dist/types/src/client/workflow/runner.d.ts +23 -0
- package/dist/types/src/client/workflow/runnerTiming.d.ts +14 -0
- package/dist/types/src/client/workflow/stepTypes.d.ts +171 -0
- package/dist/types/src/client/workflow/store.d.ts +83 -0
- package/dist/types/src/client/workflow/storeCodec.d.ts +7 -0
- package/dist/types/src/client/workflow/storeExecutionCodec.d.ts +11 -0
- package/dist/types/src/client/workflow/storeListing.d.ts +11 -0
- package/dist/types/src/client/workflow/storeMaintenance.d.ts +4 -0
- package/dist/types/src/client/workflow/storeSignals.d.ts +70 -0
- package/dist/types/src/client/workflow/subWorkflowRunner.d.ts +14 -0
- package/dist/types/src/client/workflow/types.d.ts +4 -0
- package/dist/types/src/client/workflow/unwindPlan.d.ts +87 -0
- package/dist/types/src/client/workflow/waitFor.d.ts +56 -0
- package/dist/types/src/client/workflow/workflow.d.ts +70 -0
- package/dist/types/src/client/workflow/workflowDecisions.d.ts +11 -0
- package/dist/types/src/client/workflow/workflowDefinition.d.ts +16 -0
- package/dist/types/src/client/workflow/workflowIntrospection.d.ts +5 -0
- package/dist/types/src/client/workflow/workflowValidation.d.ts +44 -0
- package/dist/types/src/config/index.d.ts +9 -0
- package/dist/types/src/config/loader.d.ts +7 -0
- package/dist/types/src/config/resolve.d.ts +59 -0
- package/dist/types/src/config/types.d.ts +88 -0
- package/dist/types/src/domain/job/constants.d.ts +14 -0
- package/dist/types/src/domain/job/create.d.ts +9 -0
- package/dist/types/src/domain/job/groupFifoOrder.d.ts +9 -0
- package/dist/types/src/domain/job/ids.d.ts +7 -0
- package/dist/types/src/domain/job/locks.d.ts +16 -0
- package/dist/types/src/domain/job/payload.d.ts +18 -0
- package/dist/types/src/domain/job/state.d.ts +23 -0
- package/dist/types/src/domain/job/terminal.d.ts +3 -0
- package/dist/types/src/domain/queue/dependencyTracker.d.ts +78 -0
- package/dist/types/src/domain/queue/dlqShard.d.ts +66 -0
- package/dist/types/src/domain/queue/groupLimiterManager.d.ts +30 -0
- package/dist/types/src/domain/queue/groupScheduler.d.ts +31 -0
- package/dist/types/src/domain/queue/groupSchedulerOrder.d.ts +6 -0
- package/dist/types/src/domain/queue/limiterManager.d.ts +68 -0
- package/dist/types/src/domain/queue/priorityQueue.d.ts +54 -0
- package/dist/types/src/domain/queue/priorityQueueOrder.d.ts +3 -0
- package/dist/types/src/domain/queue/shard/dependencies.d.ts +11 -0
- package/dist/types/src/domain/queue/shard/dlq.d.ts +26 -0
- package/dist/types/src/domain/queue/shard/keys.d.ts +19 -0
- package/dist/types/src/domain/queue/shard/lifecycle.d.ts +10 -0
- package/dist/types/src/domain/queue/shard/limits.d.ts +47 -0
- package/dist/types/src/domain/queue/shard/metrics.d.ts +32 -0
- package/dist/types/src/domain/queue/shard/state.d.ts +40 -0
- package/dist/types/src/domain/queue/shard.d.ts +7 -0
- package/dist/types/src/domain/queue/shardCounters.d.ts +35 -0
- package/dist/types/src/domain/queue/temporalIndex.d.ts +24 -0
- package/dist/types/src/domain/queue/temporalManager.d.ts +72 -0
- package/dist/types/src/domain/queue/uniqueKeyManager.d.ts +33 -0
- package/dist/types/src/domain/queue/waiterManager.d.ts +18 -0
- package/dist/types/src/domain/response/builders.d.ts +15 -0
- package/dist/types/src/domain/types/command.d.ts +2 -0
- package/dist/types/src/domain/types/commands/base.d.ts +5 -0
- package/dist/types/src/domain/types/commands/core.d.ts +107 -0
- package/dist/types/src/domain/types/commands/cron.d.ts +36 -0
- package/dist/types/src/domain/types/commands/dashboard.d.ts +13 -0
- package/dist/types/src/domain/types/commands/dlq.d.ts +44 -0
- package/dist/types/src/domain/types/commands/extended.d.ts +63 -0
- package/dist/types/src/domain/types/commands/index.d.ts +12 -0
- package/dist/types/src/domain/types/commands/limits.d.ts +108 -0
- package/dist/types/src/domain/types/commands/management.d.ts +73 -0
- package/dist/types/src/domain/types/commands/monitoring.d.ts +49 -0
- package/dist/types/src/domain/types/commands/protocol.d.ts +20 -0
- package/dist/types/src/domain/types/commands/query.d.ts +46 -0
- package/dist/types/src/domain/types/commands/union.d.ts +13 -0
- package/dist/types/src/domain/types/commands/workers.d.ts +39 -0
- package/dist/types/src/domain/types/cron.d.ts +89 -0
- package/dist/types/src/domain/types/deduplication.d.ts +43 -0
- package/dist/types/src/domain/types/dlq.d.ts +136 -0
- package/dist/types/src/domain/types/flow.d.ts +25 -0
- package/dist/types/src/domain/types/group.d.ts +26 -0
- package/dist/types/src/domain/types/job.d.ts +8 -0
- package/dist/types/src/domain/types/jobs/model.d.ts +150 -0
- package/dist/types/src/domain/types/metrics.d.ts +16 -0
- package/dist/types/src/domain/types/priorityQueue.d.ts +13 -0
- package/dist/types/src/domain/types/protocol.d.ts +5 -0
- package/dist/types/src/domain/types/queue.d.ts +110 -0
- package/dist/types/src/domain/types/response.d.ts +3 -0
- package/dist/types/src/domain/types/responses/model.d.ts +152 -0
- package/dist/types/src/domain/types/shard.d.ts +4 -0
- package/dist/types/src/domain/types/stall.d.ts +48 -0
- package/dist/types/src/domain/types/webhook.d.ts +42 -0
- package/dist/types/src/domain/types/worker.d.ts +40 -0
- package/dist/types/src/infrastructure/backup/backupTelemetry.d.ts +30 -0
- package/dist/types/src/infrastructure/backup/s3BackupConfig.d.ts +80 -0
- package/dist/types/src/infrastructure/cloud/types/config.d.ts +18 -0
- package/dist/types/src/infrastructure/cloud/types/event.d.ts +14 -0
- package/dist/types/src/infrastructure/cloud/types/snapshot.d.ts +52 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotCore.d.ts +125 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotJobs.d.ts +124 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotTelemetry.d.ts +100 -0
- package/dist/types/src/infrastructure/cloud/types.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/batchInsert.d.ts +13 -0
- package/dist/types/src/infrastructure/persistence/completedJobCountSchema.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/dependencyCompletionSchema.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/dependencyCompletionStore.d.ts +40 -0
- package/dist/types/src/infrastructure/persistence/index.d.ts +5 -0
- package/dist/types/src/infrastructure/persistence/jobOptionsBlob.d.ts +19 -0
- package/dist/types/src/infrastructure/persistence/legacyNameMigration.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/migrationProgressSchema.d.ts +2 -0
- package/dist/types/src/infrastructure/persistence/migrations.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/schema.d.ts +8 -0
- package/dist/types/src/infrastructure/persistence/sqlite/admission.d.ts +9 -0
- package/dist/types/src/infrastructure/persistence/sqlite/completed.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/control.d.ts +48 -0
- package/dist/types/src/infrastructure/persistence/sqlite/flows.d.ts +26 -0
- package/dist/types/src/infrastructure/persistence/sqlite/jobLifecycle.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/jobs.d.ts +15 -0
- package/dist/types/src/infrastructure/persistence/sqlite/lifecycle.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/sqlite/mutations.d.ts +27 -0
- package/dist/types/src/infrastructure/persistence/sqlite/queries.d.ts +23 -0
- package/dist/types/src/infrastructure/persistence/sqlite/queueDeletionSql.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/sqlite/records.d.ts +24 -0
- package/dist/types/src/infrastructure/persistence/sqlite/state.d.ts +42 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetry.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetryStore.d.ts +30 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetryWrites.d.ts +47 -0
- package/dist/types/src/infrastructure/persistence/sqlite.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/sqliteBatch.d.ts +4 -0
- package/dist/types/src/infrastructure/persistence/sqliteMigration.d.ts +5 -0
- package/dist/types/src/infrastructure/persistence/sqliteSerializer.d.ts +50 -0
- package/dist/types/src/infrastructure/persistence/statements.d.ts +86 -0
- package/dist/types/src/infrastructure/persistence/types/admission.d.ts +8 -0
- package/dist/types/src/infrastructure/persistence/types/batch.d.ts +12 -0
- package/dist/types/src/infrastructure/persistence/types/sqlite.d.ts +27 -0
- package/dist/types/src/infrastructure/persistence/writeBuffer.d.ts +48 -0
- package/dist/types/src/infrastructure/persistence/writeBufferPending.d.ts +11 -0
- package/dist/types/src/infrastructure/scheduler/cron/execution.d.ts +12 -0
- package/dist/types/src/infrastructure/scheduler/cron/persisted.d.ts +5 -0
- package/dist/types/src/infrastructure/scheduler/cron/runtime.d.ts +31 -0
- package/dist/types/src/infrastructure/scheduler/cron/validation.d.ts +3 -0
- package/dist/types/src/infrastructure/scheduler/cronParser.d.ts +45 -0
- package/dist/types/src/infrastructure/scheduler/cronScheduler.d.ts +5 -0
- package/dist/types/src/infrastructure/scheduler/types/cronScheduler.d.ts +16 -0
- package/dist/types/src/infrastructure/server/protocol/commands.d.ts +8 -0
- package/dist/types/src/infrastructure/server/protocol/frameParser.d.ts +16 -0
- package/dist/types/src/infrastructure/server/protocol/lineBuffer.d.ts +6 -0
- package/dist/types/src/infrastructure/server/protocol/validation.d.ts +10 -0
- package/dist/types/src/infrastructure/server/protocol.d.ts +6 -0
- package/dist/types/src/infrastructure/server/socketWriteQueue.d.ts +66 -0
- package/dist/types/src/infrastructure/server/types/protocol.d.ts +4 -0
- package/dist/types/src/require-bun.d.ts +13 -0
- package/dist/types/src/shared/asyncLock.d.ts +13 -0
- package/dist/types/src/shared/boundedMap.d.ts +30 -0
- package/dist/types/src/shared/boundedSet.d.ts +26 -0
- package/dist/types/src/shared/hash.d.ts +30 -0
- package/dist/types/src/shared/histogram.d.ts +23 -0
- package/dist/types/src/shared/lock.d.ts +13 -0
- package/dist/types/src/shared/lockError.d.ts +3 -0
- package/dist/types/src/shared/lockTimeout.d.ts +2 -0
- package/dist/types/src/shared/logger.d.ts +48 -0
- package/dist/types/src/shared/lru.d.ts +9 -0
- package/dist/types/src/shared/lruMap.d.ts +42 -0
- package/dist/types/src/shared/lruSet.d.ts +36 -0
- package/dist/types/src/shared/minHeap.d.ts +43 -0
- package/dist/types/src/shared/msgpack.d.ts +3 -0
- package/dist/types/src/shared/pausedView.d.ts +19 -0
- package/dist/types/src/shared/rwLock.d.ts +22 -0
- package/dist/types/src/shared/serialization.d.ts +24 -0
- package/dist/types/src/shared/skipList.d.ts +97 -0
- package/dist/types/src/shared/skipListNodes.d.ts +6 -0
- package/dist/types/src/shared/storageHealth.d.ts +9 -0
- package/dist/types/src/shared/ttlMap.d.ts +81 -0
- package/dist/types/src/shared/types/lock.d.ts +7 -0
- package/dist/types/src/shared/types/skipList.d.ts +4 -0
- package/dist/types/src/shared/version.d.ts +4 -0
- package/dist/types/src/shared/webhookValidation.d.ts +6 -0
- package/package.json +27 -9
- package/src/ack-batcher.ts +8 -5
- package/src/bunqueue/bunqueue-api.ts +1 -1
- package/src/bunqueue/bunqueue.ts +2 -1
- package/src/canonical-transport/bun-sqlite-types.ts +22 -0
- package/src/canonical-transport/dlq.ts +12 -0
- package/src/canonical-transport/embedded.ts +55 -0
- package/src/canonical-transport/runtime.ts +49 -0
- package/src/canonical-transport/thread-worker.ts +83 -0
- package/src/canonical-transport/transport.ts +153 -0
- package/src/connection.ts +25 -30
- package/src/errors.ts +3 -0
- package/src/flow-commit.ts +45 -0
- package/src/flow-plan-legacy.ts +117 -0
- package/src/flow-plan.ts +209 -0
- package/src/flow-types.ts +4 -0
- package/src/flow.ts +31 -163
- package/src/frame.ts +5 -2
- package/src/index.ts +7 -75
- package/src/job.ts +43 -9
- package/src/legacy.ts +91 -0
- package/src/observability.ts +59 -1
- package/src/queue-admin.ts +5 -5
- package/src/queue-control.ts +8 -6
- package/src/queue.ts +10 -6
- package/src/serialization.ts +93 -0
- package/src/terminal-outcome.ts +58 -0
- package/src/types.ts +3 -6
- package/src/worker-base.ts +9 -6
- package/src/worker-slot-signal.ts +23 -0
- package/src/worker.ts +11 -5
- package/dist/backpressure.js +0 -39
- package/dist/bunqueue/aging.js +0 -53
- package/dist/bunqueue/batch.js +0 -60
- package/dist/bunqueue/bunqueue-api.js +0 -116
- package/dist/bunqueue/bunqueue.js +0 -194
- package/dist/bunqueue/cancellation.js +0 -48
- package/dist/bunqueue/circuit-breaker.js +0 -69
- package/dist/bunqueue/dedup-debounce.js +0 -37
- package/dist/bunqueue/dlq-rate-limit.js +0 -65
- package/dist/bunqueue/rate-gate.js +0 -61
- package/dist/bunqueue/retry.js +0 -56
- package/dist/bunqueue/triggers.js +0 -42
- package/dist/bunqueue/ttl.js +0 -31
- package/dist/bunqueue/types.js +0 -6
- package/dist/connection-pool.js +0 -60
- package/dist/connection-types.js +0 -2
- package/dist/connection.js +0 -281
- package/dist/errors.js +0 -25
- package/dist/flow-types.js +0 -2
- package/dist/flow.js +0 -212
- package/dist/job.js +0 -155
- package/dist/observability.js +0 -110
- package/dist/queue-admin.js +0 -158
- package/dist/queue-control.js +0 -107
- package/dist/queue-query.js +0 -187
- package/dist/queue.js +0 -92
- package/dist/responses.js +0 -10
- package/dist/socket-factory.js +0 -47
- package/dist/types.js +0 -50
- package/dist/worker-base.js +0 -159
- package/dist/worker-types.js +0 -5
- package/dist/worker.js +0 -211
- /package/dist/{backpressure.d.ts → types/sdk/typescript/src/backpressure.d.ts} +0 -0
- /package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/cancellation.d.ts +0 -0
package/dist/queue-control.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue control surface: pause/drain/clean, promotion, retry and per-job
|
|
3
|
-
* mutations. Methods are merged onto Queue.prototype by queue.ts.
|
|
4
|
-
*/
|
|
5
|
-
import { UnrecoverableError } from './errors.js';
|
|
6
|
-
import { compact } from './frame.js';
|
|
7
|
-
import { MAX_STACK_LINES } from './worker-types.js';
|
|
8
|
-
export const controlMethods = {
|
|
9
|
-
async pause() {
|
|
10
|
-
await this.call({ cmd: 'Pause', queue: this.name });
|
|
11
|
-
},
|
|
12
|
-
async resume() {
|
|
13
|
-
await this.call({ cmd: 'Resume', queue: this.name });
|
|
14
|
-
},
|
|
15
|
-
async isPaused() {
|
|
16
|
-
return (await this.call({ cmd: 'IsPaused', queue: this.name })).paused === true;
|
|
17
|
-
},
|
|
18
|
-
/** Remove all waiting/delayed jobs; returns how many were dropped. */
|
|
19
|
-
async drain() {
|
|
20
|
-
const response = await this.call({ cmd: 'Drain', queue: this.name });
|
|
21
|
-
return response.count ?? 0;
|
|
22
|
-
},
|
|
23
|
-
async obliterate() {
|
|
24
|
-
await this.call({ cmd: 'Obliterate', queue: this.name });
|
|
25
|
-
},
|
|
26
|
-
/** Remove old jobs; returns how many were removed. */
|
|
27
|
-
async clean(graceMs, limit, state) {
|
|
28
|
-
const response = await this.call(compact({ cmd: 'Clean', queue: this.name, grace: graceMs, limit, state }));
|
|
29
|
-
return response.count ?? 0;
|
|
30
|
-
},
|
|
31
|
-
async remove(id) {
|
|
32
|
-
await this.call({ cmd: 'Cancel', id });
|
|
33
|
-
},
|
|
34
|
-
async discard(id) {
|
|
35
|
-
await this.call({ cmd: 'Discard', id });
|
|
36
|
-
},
|
|
37
|
-
async promoteJob(id) {
|
|
38
|
-
await this.call({ cmd: 'Promote', id });
|
|
39
|
-
},
|
|
40
|
-
/** Promote delayed jobs to waiting; returns how many were promoted. */
|
|
41
|
-
async promoteJobs(opts = {}) {
|
|
42
|
-
const response = await this.call(compact({ cmd: 'PromoteJobs', queue: this.name, count: opts.count }));
|
|
43
|
-
return response.count ?? 0;
|
|
44
|
-
},
|
|
45
|
-
/** BullMQ contract: failed → waiting. */
|
|
46
|
-
async retryJob(id) {
|
|
47
|
-
await this.call({ cmd: 'MoveToWait', id });
|
|
48
|
-
},
|
|
49
|
-
async retryJobs(opts = {}) {
|
|
50
|
-
if (opts.state === 'completed') {
|
|
51
|
-
await this.call({ cmd: 'RetryCompleted', queue: this.name });
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// `count` caps how many DLQ entries are retried (server >= 2.8.29). Older
|
|
55
|
-
// servers ignore the field and retry the whole DLQ — forward-compatible.
|
|
56
|
-
await this.call(compact({ cmd: 'RetryDlq', queue: this.name, count: opts.count }));
|
|
57
|
-
},
|
|
58
|
-
async retryCompleted(id) {
|
|
59
|
-
await this.call(compact({ cmd: 'RetryCompleted', queue: this.name, id }));
|
|
60
|
-
},
|
|
61
|
-
// ----------------------------------------------------------- job mutations
|
|
62
|
-
async updateJobProgress(id, progress, message) {
|
|
63
|
-
await this.call(compact({ cmd: 'Progress', id, progress, message }));
|
|
64
|
-
},
|
|
65
|
-
async updateJobData(id, data) {
|
|
66
|
-
await this.call({ cmd: 'Update', id, data });
|
|
67
|
-
},
|
|
68
|
-
async changeJobPriority(id, opts) {
|
|
69
|
-
await this.call({ cmd: 'ChangePriority', id, priority: opts.priority, lifo: opts.lifo });
|
|
70
|
-
},
|
|
71
|
-
async changeJobDelay(id, delayMs) {
|
|
72
|
-
await this.call({ cmd: 'ChangeDelay', id, delay: delayMs });
|
|
73
|
-
},
|
|
74
|
-
async moveJobToWait(id) {
|
|
75
|
-
await this.call({ cmd: 'MoveToWait', id });
|
|
76
|
-
},
|
|
77
|
-
async moveJobToDelayed(id, delayMs) {
|
|
78
|
-
await this.call({ cmd: 'MoveToDelayed', id, delay: delayMs });
|
|
79
|
-
},
|
|
80
|
-
async extendJobLock(id, token, durationMs) {
|
|
81
|
-
await this.call({ cmd: 'ExtendLock', id, token, duration: durationMs });
|
|
82
|
-
},
|
|
83
|
-
async moveJobToCompleted(id, returnValue, token) {
|
|
84
|
-
await this.call(compact({ cmd: 'ACK', id, result: returnValue, token }));
|
|
85
|
-
},
|
|
86
|
-
/**
|
|
87
|
-
* Explicit failure path: mirrors the worker's FAIL wire so the stacktrace
|
|
88
|
-
* and the UnrecoverableError "do not retry" intent are persisted (#111
|
|
89
|
-
* silent-loss class), not just the message.
|
|
90
|
-
*/
|
|
91
|
-
async moveJobToFailed(id, error, token) {
|
|
92
|
-
const err = typeof error === 'string' ? undefined : error;
|
|
93
|
-
const message = err ? err.message || err.name : error;
|
|
94
|
-
// Keep the FIRST lines (message + throw site), like the worker path.
|
|
95
|
-
const stack = err
|
|
96
|
-
? (err.stack ?? err.message).split('\n').slice(0, MAX_STACK_LINES)
|
|
97
|
-
: undefined;
|
|
98
|
-
await this.call(compact({
|
|
99
|
-
cmd: 'FAIL',
|
|
100
|
-
id,
|
|
101
|
-
error: message,
|
|
102
|
-
stack,
|
|
103
|
-
unrecoverable: err instanceof UnrecoverableError ? true : undefined,
|
|
104
|
-
token,
|
|
105
|
-
}));
|
|
106
|
-
},
|
|
107
|
-
};
|
package/dist/queue-query.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue query surface: job lookup, state, results, counts, logs, children.
|
|
3
|
-
* Methods are merged onto Queue.prototype by queue.ts.
|
|
4
|
-
*/
|
|
5
|
-
import { CommandError, CommandTimeoutError } from './errors.js';
|
|
6
|
-
import { compact } from './frame.js';
|
|
7
|
-
import { Job } from './job.js';
|
|
8
|
-
function unwrapValues(response) {
|
|
9
|
-
const data = (response.data ?? {});
|
|
10
|
-
return (data.values ?? response.values ?? data ?? {});
|
|
11
|
-
}
|
|
12
|
-
export const queryMethods = {
|
|
13
|
-
async getJob(id) {
|
|
14
|
-
try {
|
|
15
|
-
const response = await this.call({ cmd: 'GetJob', id });
|
|
16
|
-
return response.job ? new Job(response.job, this.connection) : null;
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
// Only the server's 'Job not found' maps to null; connection loss,
|
|
20
|
-
// timeouts and other server errors must surface.
|
|
21
|
-
if (err instanceof CommandError && /not found/i.test(err.message))
|
|
22
|
-
return null;
|
|
23
|
-
throw err;
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
async getJobByCustomId(customId) {
|
|
27
|
-
try {
|
|
28
|
-
const response = await this.call({ cmd: 'GetJobByCustomId', customId });
|
|
29
|
-
return response.job ? new Job(response.job, this.connection) : null;
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
if (err instanceof CommandError && /not found/i.test(err.message))
|
|
33
|
-
return null;
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
/** BullMQ v5: resolve the job id registered under a deduplication id. */
|
|
38
|
-
async getDeduplicationJobId(deduplicationId) {
|
|
39
|
-
const job = await this.getJobByCustomId(deduplicationId);
|
|
40
|
-
return job ? job.id : null;
|
|
41
|
-
},
|
|
42
|
-
async getJobs(opts = {}) {
|
|
43
|
-
const start = opts.start ?? 0;
|
|
44
|
-
const end = opts.end !== undefined && opts.end >= 0 ? opts.end : 1000;
|
|
45
|
-
const response = await this.call(compact({
|
|
46
|
-
cmd: 'GetJobs',
|
|
47
|
-
queue: this.name,
|
|
48
|
-
state: opts.state,
|
|
49
|
-
offset: start,
|
|
50
|
-
limit: end - start,
|
|
51
|
-
}));
|
|
52
|
-
return (response.jobs ?? []).map((raw) => new Job(raw, this.connection));
|
|
53
|
-
},
|
|
54
|
-
getWaiting(start, end) {
|
|
55
|
-
// Only the 'waiting' bucket — prioritized jobs live in a separate bucket
|
|
56
|
-
// (getPrioritized), matching BullMQ and the Python SDK / reference client.
|
|
57
|
-
return this.getJobs({ state: 'waiting', start, end });
|
|
58
|
-
},
|
|
59
|
-
getDelayed(start, end) {
|
|
60
|
-
return this.getJobs({ state: 'delayed', start, end });
|
|
61
|
-
},
|
|
62
|
-
getActive(start, end) {
|
|
63
|
-
return this.getJobs({ state: 'active', start, end });
|
|
64
|
-
},
|
|
65
|
-
getCompleted(start, end) {
|
|
66
|
-
return this.getJobs({ state: 'completed', start, end });
|
|
67
|
-
},
|
|
68
|
-
getFailed(start, end) {
|
|
69
|
-
return this.getJobs({ state: 'failed', start, end });
|
|
70
|
-
},
|
|
71
|
-
getPrioritized(start, end) {
|
|
72
|
-
return this.getJobs({ state: 'prioritized', start, end });
|
|
73
|
-
},
|
|
74
|
-
getWaitingChildren(start, end) {
|
|
75
|
-
return this.getJobs({ state: 'waiting-children', start, end });
|
|
76
|
-
},
|
|
77
|
-
async getJobState(id) {
|
|
78
|
-
return (await this.call({ cmd: 'GetState', id })).state;
|
|
79
|
-
},
|
|
80
|
-
async getResult(id) {
|
|
81
|
-
return (await this.call({ cmd: 'GetResult', id })).result;
|
|
82
|
-
},
|
|
83
|
-
async getChildrenValues(id) {
|
|
84
|
-
return unwrapValues(await this.call({ cmd: 'GetChildrenValues', id }));
|
|
85
|
-
},
|
|
86
|
-
async getFailedChildrenValues(id) {
|
|
87
|
-
return unwrapValues(await this.call({ cmd: 'GetFailedChildrenValues', id }));
|
|
88
|
-
},
|
|
89
|
-
async getIgnoredChildrenFailures(id) {
|
|
90
|
-
return unwrapValues(await this.call({ cmd: 'GetIgnoredChildrenFailures', id }));
|
|
91
|
-
},
|
|
92
|
-
/** Detach a child job from its parent's dependency list. */
|
|
93
|
-
async removeChildDependency(id) {
|
|
94
|
-
await this.call({ cmd: 'RemoveChildDependency', id });
|
|
95
|
-
},
|
|
96
|
-
/** Remove all still-unprocessed children of a parent job. */
|
|
97
|
-
async removeUnprocessedChildren(id) {
|
|
98
|
-
await this.call({ cmd: 'RemoveUnprocessedChildren', id });
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* Block until the job completes; returns its result.
|
|
102
|
-
* The server's WaitJob waiter resolves only on completion, replying
|
|
103
|
-
* `{ok:true, completed:false}` (no result) otherwise — so returning undefined
|
|
104
|
-
* would be indistinguishable from a genuine undefined result. On
|
|
105
|
-
* non-completion we probe the state: a `failed` job throws CommandError (it
|
|
106
|
-
* will not complete), everything else throws CommandTimeoutError.
|
|
107
|
-
*/
|
|
108
|
-
async waitForJob(id, ttlMs = 30_000) {
|
|
109
|
-
// The server validates 0 <= timeout <= 600000: clamp instead of erroring.
|
|
110
|
-
ttlMs = Math.min(Math.max(ttlMs, 0), 600_000);
|
|
111
|
-
const response = await this.call({ cmd: 'WaitJob', id, timeout: ttlMs }, ttlMs + 5000);
|
|
112
|
-
if (response.completed !== true) {
|
|
113
|
-
let state;
|
|
114
|
-
try {
|
|
115
|
-
state = await this.getJobState(id);
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
/* ignore probe failure; fall through to timeout */
|
|
119
|
-
}
|
|
120
|
-
if (state === 'failed')
|
|
121
|
-
throw new CommandError(`job ${id} failed before completion`);
|
|
122
|
-
throw new CommandTimeoutError(`waitUntilFinished timed out after ${ttlMs}ms`);
|
|
123
|
-
}
|
|
124
|
-
return response.result;
|
|
125
|
-
},
|
|
126
|
-
/** BullMQ v5 alias for waitForJob (queueEvents param unused over TCP). */
|
|
127
|
-
waitJobUntilFinished(id, _queueEvents, ttlMs) {
|
|
128
|
-
return this.waitForJob(id, ttlMs);
|
|
129
|
-
},
|
|
130
|
-
async getProgress(id) {
|
|
131
|
-
const response = await this.call({ cmd: 'GetProgress', id });
|
|
132
|
-
return { progress: response.progress ?? 0, message: response.message ?? null };
|
|
133
|
-
},
|
|
134
|
-
// ------------------------------------------------------------------- counts
|
|
135
|
-
async getJobCounts() {
|
|
136
|
-
return (await this.call({ cmd: 'GetJobCounts', queue: this.name })).counts;
|
|
137
|
-
},
|
|
138
|
-
async getWaitingCount() {
|
|
139
|
-
// 'waiting' only — prioritized jobs are counted by getPrioritizedCount,
|
|
140
|
-
// matching BullMQ and the Python SDK / reference client.
|
|
141
|
-
return (await this.getJobCounts()).waiting;
|
|
142
|
-
},
|
|
143
|
-
async getActiveCount() {
|
|
144
|
-
return (await this.getJobCounts()).active;
|
|
145
|
-
},
|
|
146
|
-
async getCompletedCount() {
|
|
147
|
-
return (await this.getJobCounts()).completed;
|
|
148
|
-
},
|
|
149
|
-
async getFailedCount() {
|
|
150
|
-
return (await this.getJobCounts()).failed;
|
|
151
|
-
},
|
|
152
|
-
async getDelayedCount() {
|
|
153
|
-
return (await this.getJobCounts()).delayed;
|
|
154
|
-
},
|
|
155
|
-
async getPrioritizedCount() {
|
|
156
|
-
return (await this.getJobCounts()).prioritized;
|
|
157
|
-
},
|
|
158
|
-
async getWaitingChildrenCount() {
|
|
159
|
-
return (await this.getJobCounts())['waiting-children'];
|
|
160
|
-
},
|
|
161
|
-
async count() {
|
|
162
|
-
return (await this.call({ cmd: 'Count', queue: this.name })).count ?? 0;
|
|
163
|
-
},
|
|
164
|
-
async getCountsPerPriority() {
|
|
165
|
-
const response = await this.call({ cmd: 'GetCountsPerPriority', queue: this.name });
|
|
166
|
-
return (response.counts ?? response.data ?? {});
|
|
167
|
-
},
|
|
168
|
-
// --------------------------------------------------------------------- logs
|
|
169
|
-
async addJobLog(id, message, level) {
|
|
170
|
-
await this.call(compact({ cmd: 'AddLog', id, message, level }));
|
|
171
|
-
},
|
|
172
|
-
async getJobLogs(id, start, end) {
|
|
173
|
-
const response = await this.call(compact({ cmd: 'GetLogs', id, start, end }));
|
|
174
|
-
const data = (response.data ?? {});
|
|
175
|
-
const logs = (data.logs ?? response.logs ?? []);
|
|
176
|
-
// Format as `[level] message` (reference client parity); never drop level.
|
|
177
|
-
return logs.map((row) => {
|
|
178
|
-
if (typeof row === 'string')
|
|
179
|
-
return row;
|
|
180
|
-
const r = row;
|
|
181
|
-
return r.level ? `[${r.level}] ${r.message}` : String(r.message ?? row);
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
async clearJobLogs(id, keepLogs) {
|
|
185
|
-
await this.call(compact({ cmd: 'ClearLogs', id, keepLogs }));
|
|
186
|
-
},
|
|
187
|
-
};
|
package/dist/queue.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue: producer + management API over the bunqueue TCP protocol.
|
|
3
|
-
* Method surface mirrors the official TS client (TCP mode).
|
|
4
|
-
*
|
|
5
|
-
* The class is composed from area modules kept under 250 lines each:
|
|
6
|
-
* queue-query.ts (query/counts/logs), queue-control.ts (state control,
|
|
7
|
-
* job mutations) and queue-admin.ts (DLQ, configs, schedulers, webhooks,
|
|
8
|
-
* monitoring). Methods are merged onto the prototype; declaration merging
|
|
9
|
-
* exposes them on the type.
|
|
10
|
-
*/
|
|
11
|
-
import { Connection } from './connection.js';
|
|
12
|
-
import { ConnectionPool } from './connection-pool.js';
|
|
13
|
-
import { Job } from './job.js';
|
|
14
|
-
import { adminMethods } from './queue-admin.js';
|
|
15
|
-
import { controlMethods } from './queue-control.js';
|
|
16
|
-
import { queryMethods } from './queue-query.js';
|
|
17
|
-
import { jobPayload, wireJobOptions } from './types.js';
|
|
18
|
-
// biome-ignore lint/suspicious/noUnsafeDeclarationMerging: prototype-mixin composition — Object.assign at the bottom installs exactly the methods the merged interface declares
|
|
19
|
-
export class Queue {
|
|
20
|
-
name;
|
|
21
|
-
connection;
|
|
22
|
-
ownsConnection;
|
|
23
|
-
constructor(name, opts = {}) {
|
|
24
|
-
this.name = name;
|
|
25
|
-
const connOptions = {
|
|
26
|
-
host: opts.host,
|
|
27
|
-
port: opts.port,
|
|
28
|
-
token: opts.token,
|
|
29
|
-
tls: opts.tls,
|
|
30
|
-
commandTimeoutMs: opts.commandTimeoutMs,
|
|
31
|
-
maxInFlight: opts.maxInFlight,
|
|
32
|
-
logger: opts.logger,
|
|
33
|
-
onTelemetry: opts.onTelemetry,
|
|
34
|
-
};
|
|
35
|
-
this.connection =
|
|
36
|
-
opts.connection ??
|
|
37
|
-
(opts.poolSize && opts.poolSize > 1
|
|
38
|
-
? new ConnectionPool(opts.poolSize, connOptions)
|
|
39
|
-
: new Connection(connOptions));
|
|
40
|
-
this.ownsConnection = opts.connection === undefined;
|
|
41
|
-
}
|
|
42
|
-
/** Send a raw command on this queue's connection (used by area modules). */
|
|
43
|
-
call(command, timeoutMs) {
|
|
44
|
-
return this.connection.call(command, timeoutMs);
|
|
45
|
-
}
|
|
46
|
-
// ------------------------------------------------------------------ produce
|
|
47
|
-
/** Add a job; returns a Job stub carrying the assigned id. */
|
|
48
|
-
async add(name, data, opts) {
|
|
49
|
-
const payload = jobPayload(name, data);
|
|
50
|
-
const response = await this.call({
|
|
51
|
-
cmd: 'PUSH',
|
|
52
|
-
queue: this.name,
|
|
53
|
-
data: payload,
|
|
54
|
-
...wireJobOptions(opts),
|
|
55
|
-
});
|
|
56
|
-
return new Job({ id: response.id, queue: this.name, data: payload }, this.connection);
|
|
57
|
-
}
|
|
58
|
-
/** Add many jobs in one round-trip; returns Job stubs. */
|
|
59
|
-
async addBulk(jobs) {
|
|
60
|
-
const inputs = jobs.map((entry) => {
|
|
61
|
-
const opts = wireJobOptions(entry.opts);
|
|
62
|
-
// PUSHB entries are JobInput, whose custom-id field is `customId` —
|
|
63
|
-
// unlike single PUSH which renames `jobId`->`customId` server-side.
|
|
64
|
-
// Without this the batch custom id is silently dropped (idempotency /
|
|
65
|
-
// getJobByCustomId broken).
|
|
66
|
-
if (opts.jobId !== undefined) {
|
|
67
|
-
opts.customId = opts.jobId;
|
|
68
|
-
delete opts.jobId;
|
|
69
|
-
}
|
|
70
|
-
return { data: jobPayload(entry.name, entry.data), ...opts };
|
|
71
|
-
});
|
|
72
|
-
const response = await this.call({ cmd: 'PUSHB', queue: this.name, jobs: inputs });
|
|
73
|
-
const ids = (response.ids ?? []);
|
|
74
|
-
return ids.map((id, i) => new Job({ id, queue: this.name, data: inputs[i].data }, this.connection));
|
|
75
|
-
}
|
|
76
|
-
// ---------------------------------------------------------------- lifecycle
|
|
77
|
-
ping() {
|
|
78
|
-
return this.connection.ping();
|
|
79
|
-
}
|
|
80
|
-
async waitUntilReady() {
|
|
81
|
-
await this.connection.connect();
|
|
82
|
-
}
|
|
83
|
-
close() {
|
|
84
|
-
if (this.ownsConnection)
|
|
85
|
-
this.connection.close();
|
|
86
|
-
}
|
|
87
|
-
/** BullMQ v5 alias for close(). */
|
|
88
|
-
async disconnect() {
|
|
89
|
-
this.close();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
Object.assign(Queue.prototype, queryMethods, controlMethods, adminMethods);
|
package/dist/responses.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed server-response shapes, mirroring the server's response builders
|
|
3
|
-
* (src/domain/types/response.ts). `Connection.call<R>()` and `Queue.call<R>()`
|
|
4
|
-
* are generic over these, so call sites read `response.job` / `response.counts`
|
|
5
|
-
* with real types instead of casting `as Record<string, unknown>`.
|
|
6
|
-
*
|
|
7
|
-
* These narrow the loose transport `Response`; the runtime value is whatever
|
|
8
|
-
* the server sent, so only assert the shape a given command actually returns.
|
|
9
|
-
*/
|
|
10
|
-
export {};
|
package/dist/socket-factory.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/** Socket factory: opens a plain or TLS socket with a connect timeout. */
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { connect as netConnect } from 'node:net';
|
|
4
|
-
import { connect as tlsConnect } from 'node:tls';
|
|
5
|
-
import { ConnectionClosedError } from './errors.js';
|
|
6
|
-
export function openSocket(host, port, tls, connectTimeoutMs) {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
let settled = false;
|
|
9
|
-
const timer = setTimeout(() => {
|
|
10
|
-
if (settled)
|
|
11
|
-
return;
|
|
12
|
-
settled = true;
|
|
13
|
-
socket.destroy();
|
|
14
|
-
reject(new ConnectionClosedError(`connect timeout to ${host}:${port}`));
|
|
15
|
-
}, connectTimeoutMs);
|
|
16
|
-
const onError = (err) => {
|
|
17
|
-
if (settled)
|
|
18
|
-
return;
|
|
19
|
-
settled = true;
|
|
20
|
-
clearTimeout(timer);
|
|
21
|
-
reject(new ConnectionClosedError(`connect failed: ${err.message}`));
|
|
22
|
-
};
|
|
23
|
-
const onReady = () => {
|
|
24
|
-
if (settled)
|
|
25
|
-
return;
|
|
26
|
-
settled = true;
|
|
27
|
-
clearTimeout(timer);
|
|
28
|
-
socket.off('error', onError);
|
|
29
|
-
resolve(socket);
|
|
30
|
-
};
|
|
31
|
-
let socket;
|
|
32
|
-
if (tls) {
|
|
33
|
-
const tlsOpts = { host: host, port: port };
|
|
34
|
-
if (typeof tls === 'object') {
|
|
35
|
-
if (tls.caFile)
|
|
36
|
-
tlsOpts.ca = readFileSync(tls.caFile);
|
|
37
|
-
if (tls.rejectUnauthorized === false)
|
|
38
|
-
tlsOpts.rejectUnauthorized = false;
|
|
39
|
-
}
|
|
40
|
-
socket = tlsConnect(tlsOpts, onReady);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
socket = netConnect({ host: host, port: port }, onReady);
|
|
44
|
-
}
|
|
45
|
-
socket.on('error', onError);
|
|
46
|
-
});
|
|
47
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/** Shared option types + wire mapping, mirroring the official client. */
|
|
2
|
-
import { compact } from './frame.js';
|
|
3
|
-
/** Map SDK JobOptions to the PUSH/PUSHB wire fields (undefined keys dropped). */
|
|
4
|
-
export function wireJobOptions(opts = {}) {
|
|
5
|
-
return compact({
|
|
6
|
-
priority: opts.priority,
|
|
7
|
-
delay: opts.delay,
|
|
8
|
-
maxAttempts: opts.attempts,
|
|
9
|
-
backoff: opts.backoff,
|
|
10
|
-
ttl: opts.ttl,
|
|
11
|
-
timeout: opts.timeout,
|
|
12
|
-
jobId: opts.jobId,
|
|
13
|
-
uniqueKey: opts.deduplication?.id,
|
|
14
|
-
dedup: opts.deduplication
|
|
15
|
-
? compact({
|
|
16
|
-
ttl: opts.deduplication.ttl,
|
|
17
|
-
extend: opts.deduplication.extend,
|
|
18
|
-
replace: opts.deduplication.replace,
|
|
19
|
-
})
|
|
20
|
-
: undefined,
|
|
21
|
-
dependsOn: opts.dependsOn,
|
|
22
|
-
parentId: opts.parentId,
|
|
23
|
-
childrenIds: opts.childrenIds,
|
|
24
|
-
tags: opts.tags,
|
|
25
|
-
groupId: opts.groupId,
|
|
26
|
-
lifo: opts.lifo,
|
|
27
|
-
removeOnComplete: typeof opts.removeOnComplete === 'boolean' ? opts.removeOnComplete : undefined,
|
|
28
|
-
removeOnFail: typeof opts.removeOnFail === 'boolean' ? opts.removeOnFail : undefined,
|
|
29
|
-
stallTimeout: opts.stallTimeout,
|
|
30
|
-
durable: opts.durable,
|
|
31
|
-
repeat: opts.repeat,
|
|
32
|
-
debounceId: opts.debounce?.id,
|
|
33
|
-
debounceTtl: opts.debounce?.ttl,
|
|
34
|
-
stackTraceLimit: opts.stackTraceLimit,
|
|
35
|
-
keepLogs: opts.keepLogs,
|
|
36
|
-
sizeLimit: opts.sizeLimit,
|
|
37
|
-
timestamp: opts.timestamp,
|
|
38
|
-
failParentOnFailure: opts.failParentOnFailure,
|
|
39
|
-
removeDependencyOnFailure: opts.removeDependencyOnFailure,
|
|
40
|
-
ignoreDependencyOnFailure: opts.ignoreDependencyOnFailure,
|
|
41
|
-
continueParentOnFailure: opts.continueParentOnFailure,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** The job name travels inside `data`, mirroring the official client. */
|
|
45
|
-
export function jobPayload(name, data) {
|
|
46
|
-
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
47
|
-
return { name, ...data };
|
|
48
|
-
}
|
|
49
|
-
return data === undefined || data === null ? { name } : { name, payload: data };
|
|
50
|
-
}
|
package/dist/worker-base.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WorkerBase: lifecycle state, cooperative cancellation and safe command
|
|
3
|
-
* dispatch shared by the Worker pull loop (worker.ts).
|
|
4
|
-
*/
|
|
5
|
-
import { randomBytes } from 'node:crypto';
|
|
6
|
-
import { EventEmitter } from 'node:events';
|
|
7
|
-
import { hostname } from 'node:os';
|
|
8
|
-
import { Connection } from './connection.js';
|
|
9
|
-
import { MAX_POLL_TIMEOUT_MS, sleep, } from './worker-types.js';
|
|
10
|
-
export class WorkerBase extends EventEmitter {
|
|
11
|
-
queue;
|
|
12
|
-
concurrency;
|
|
13
|
-
batchSize;
|
|
14
|
-
pollTimeoutMs;
|
|
15
|
-
lockTtlMs;
|
|
16
|
-
heartbeatIntervalS;
|
|
17
|
-
workerId;
|
|
18
|
-
name;
|
|
19
|
-
connection;
|
|
20
|
-
active = new Map(); // job id -> lock token
|
|
21
|
-
cancelledJobs = new Set();
|
|
22
|
-
stopped = false;
|
|
23
|
-
paused = false;
|
|
24
|
-
closedFlag = false;
|
|
25
|
-
running = false;
|
|
26
|
-
wasBusy = false;
|
|
27
|
-
processed = 0;
|
|
28
|
-
failedCount = 0;
|
|
29
|
-
readyPromise;
|
|
30
|
-
readyResolve = null;
|
|
31
|
-
readyFired = false;
|
|
32
|
-
loopPromise = null;
|
|
33
|
-
heartbeatTimer = null;
|
|
34
|
-
registeredGeneration = -1;
|
|
35
|
-
constructor(queue, opts = {}) {
|
|
36
|
-
super();
|
|
37
|
-
if ((opts.concurrency ?? 4) < 1)
|
|
38
|
-
throw new Error('concurrency must be >= 1');
|
|
39
|
-
this.queue = queue;
|
|
40
|
-
this.concurrency = opts.concurrency ?? 4;
|
|
41
|
-
// The server rejects PULLB count > 1000 (handlers/core.ts) — an unclamped
|
|
42
|
-
// batchSize would wedge the pull loop in a permanent error cycle. The
|
|
43
|
-
// finite-guard also catches NaN, which would otherwise pass both bounds.
|
|
44
|
-
const rawBatch = opts.batchSize ?? 10;
|
|
45
|
-
this.batchSize = Number.isFinite(rawBatch) ? Math.min(Math.max(1, rawBatch), 1000) : 10;
|
|
46
|
-
this.pollTimeoutMs = Math.min(opts.pollTimeoutMs ?? 5000, MAX_POLL_TIMEOUT_MS);
|
|
47
|
-
this.lockTtlMs = opts.lockTtlMs ?? 30_000;
|
|
48
|
-
this.heartbeatIntervalS = opts.heartbeatIntervalS ?? 10;
|
|
49
|
-
this.workerId = `ts-${hostname()}-${process.pid}-${randomBytes(4).toString('hex')}`;
|
|
50
|
-
this.name = opts.name ?? this.workerId;
|
|
51
|
-
this.connection = new Connection({
|
|
52
|
-
host: opts.host,
|
|
53
|
-
port: opts.port,
|
|
54
|
-
token: opts.token,
|
|
55
|
-
tls: opts.tls,
|
|
56
|
-
logger: opts.logger,
|
|
57
|
-
onTelemetry: opts.onTelemetry,
|
|
58
|
-
});
|
|
59
|
-
this.readyPromise = new Promise((resolve) => {
|
|
60
|
-
this.readyResolve = resolve;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
pause() {
|
|
64
|
-
this.paused = true;
|
|
65
|
-
}
|
|
66
|
-
resume() {
|
|
67
|
-
this.paused = false;
|
|
68
|
-
}
|
|
69
|
-
isRunning() {
|
|
70
|
-
return this.running && !this.closedFlag;
|
|
71
|
-
}
|
|
72
|
-
isPaused() {
|
|
73
|
-
return this.paused;
|
|
74
|
-
}
|
|
75
|
-
isClosed() {
|
|
76
|
-
return this.closedFlag;
|
|
77
|
-
}
|
|
78
|
-
async waitUntilReady() {
|
|
79
|
-
await this.readyPromise;
|
|
80
|
-
}
|
|
81
|
-
on(event, listener) {
|
|
82
|
-
if (event === 'ready' && this.readyFired)
|
|
83
|
-
listener();
|
|
84
|
-
return super.on(event, listener);
|
|
85
|
-
}
|
|
86
|
-
once(event, listener) {
|
|
87
|
-
if (event === 'ready' && this.readyFired) {
|
|
88
|
-
listener();
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
return super.once(event, listener);
|
|
92
|
-
}
|
|
93
|
-
off(event, listener) {
|
|
94
|
-
return super.off(event, listener);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Cooperative cancel of a locally active job (mirrors the official client):
|
|
98
|
-
* marks the job and emits 'cancelled'; the processor is expected to check
|
|
99
|
-
* isJobCancelled() and abort. Returns false if the job is not active here.
|
|
100
|
-
*/
|
|
101
|
-
cancelJob(jobId, reason) {
|
|
102
|
-
if (this.active.has(jobId)) {
|
|
103
|
-
this.cancelledJobs.add(jobId);
|
|
104
|
-
this.emit('cancelled', { jobId, reason: reason ?? 'Job cancelled by worker' });
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
cancelAllJobs(reason) {
|
|
110
|
-
for (const jobId of this.active.keys()) {
|
|
111
|
-
this.cancelledJobs.add(jobId);
|
|
112
|
-
this.emit('cancelled', { jobId, reason: reason ?? 'All jobs cancelled' });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
isJobCancelled(jobId) {
|
|
116
|
-
return this.cancelledJobs.has(jobId);
|
|
117
|
-
}
|
|
118
|
-
/** Graceful shutdown: stop pulling, wait for in-flight jobs.
|
|
119
|
-
* With `force` the wait for in-flight jobs is skipped (parity with the
|
|
120
|
-
* official client's `close(force)`). */
|
|
121
|
-
async close(force = false) {
|
|
122
|
-
if (this.closedFlag)
|
|
123
|
-
return;
|
|
124
|
-
this.stopped = true;
|
|
125
|
-
if (this.loopPromise)
|
|
126
|
-
await this.loopPromise;
|
|
127
|
-
await this.beforeClose(); // flush any batched ACKs before draining
|
|
128
|
-
while (!force && this.active.size > 0)
|
|
129
|
-
await sleep(20);
|
|
130
|
-
if (this.heartbeatTimer) {
|
|
131
|
-
clearInterval(this.heartbeatTimer);
|
|
132
|
-
this.heartbeatTimer = null;
|
|
133
|
-
}
|
|
134
|
-
// Only unregister when the loop actually registered (autorun: false and
|
|
135
|
-
// never run() means the server does not know this worker).
|
|
136
|
-
if (this.registeredGeneration >= 0) {
|
|
137
|
-
await this.safeCall({ cmd: 'UnregisterWorker', workerId: this.workerId });
|
|
138
|
-
}
|
|
139
|
-
this.connection.close();
|
|
140
|
-
this.closedFlag = true;
|
|
141
|
-
this.running = false;
|
|
142
|
-
this.emit('closed');
|
|
143
|
-
}
|
|
144
|
-
/** Dispatch a command, routing failures to 'error'. Returns whether the
|
|
145
|
-
* command reached the server — callers gate success-only side effects
|
|
146
|
-
* ('completed'/'failed' emits, counters) on it. */
|
|
147
|
-
async safeCall(command) {
|
|
148
|
-
try {
|
|
149
|
-
await this.connection.call(command);
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
catch (err) {
|
|
153
|
-
this.emit('error', err instanceof Error ? err : new Error(String(err)));
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/** Hook run during close() before draining in-flight jobs (see Worker). */
|
|
158
|
-
async beforeClose() { }
|
|
159
|
-
}
|
package/dist/worker-types.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Worker option types and shared constants. */
|
|
2
|
-
export const MAX_POLL_TIMEOUT_MS = 30_000;
|
|
3
|
-
export const MAX_STACK_LINES = 20;
|
|
4
|
-
export const RECONNECT_BACKOFF_MS = [500, 1000, 2000, 5000];
|
|
5
|
-
export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|