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/flow.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FlowProducer: parent/children job trees, chains and fan-in flows.
|
|
3
|
-
* Mirrors the official client's TCP flow logic (bottom-up creation,
|
|
4
|
-
* UpdateParent fix-up, rollback via Cancel on failure).
|
|
5
|
-
*/
|
|
6
|
-
import { Connection } from './connection.js';
|
|
7
|
-
import { CommandError } from './errors.js';
|
|
8
|
-
import { compact } from './frame.js';
|
|
9
|
-
import { Job } from './job.js';
|
|
10
|
-
import { jobPayload, wireJobOptions } from './types.js';
|
|
11
|
-
export class FlowProducer {
|
|
12
|
-
connection;
|
|
13
|
-
ownsConnection;
|
|
14
|
-
constructor(opts = {}) {
|
|
15
|
-
this.connection =
|
|
16
|
-
opts.connection ??
|
|
17
|
-
new Connection({
|
|
18
|
-
host: opts.host,
|
|
19
|
-
port: opts.port,
|
|
20
|
-
token: opts.token,
|
|
21
|
-
tls: opts.tls,
|
|
22
|
-
logger: opts.logger,
|
|
23
|
-
onTelemetry: opts.onTelemetry,
|
|
24
|
-
});
|
|
25
|
-
this.ownsConnection = opts.connection === undefined;
|
|
26
|
-
}
|
|
27
|
-
/** Add a flow tree. Children are created (and processed) BEFORE their parent. */
|
|
28
|
-
async add(flow) {
|
|
29
|
-
const created = [];
|
|
30
|
-
try {
|
|
31
|
-
return await this.addNode(flow, null, created);
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
await this.rollback(created);
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async addBulk(flows) {
|
|
39
|
-
const created = [];
|
|
40
|
-
const results = [];
|
|
41
|
-
try {
|
|
42
|
-
for (const flow of flows) {
|
|
43
|
-
results.push(await this.addNode(flow, null, created));
|
|
44
|
-
}
|
|
45
|
-
return results;
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
await this.rollback(created);
|
|
49
|
-
throw err;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/** Fetch a flow tree starting from a job id (recursive over childrenIds). */
|
|
53
|
-
getFlow(opts) {
|
|
54
|
-
return this.fetchNode(opts.id, opts.depth ?? Number.POSITIVE_INFINITY, opts.maxChildren, new Set());
|
|
55
|
-
}
|
|
56
|
-
/** Add a sequential chain: step[0] → step[1] → ... via dependsOn. */
|
|
57
|
-
async addChain(steps) {
|
|
58
|
-
if (steps.length === 0)
|
|
59
|
-
return { jobIds: [] };
|
|
60
|
-
const jobIds = [];
|
|
61
|
-
let prevId = null;
|
|
62
|
-
try {
|
|
63
|
-
for (const step of steps) {
|
|
64
|
-
const data = compact({
|
|
65
|
-
...jobPayload(step.name, step.data),
|
|
66
|
-
__flowParentId: prevId ?? undefined,
|
|
67
|
-
});
|
|
68
|
-
// Connection.call compacts internally, so no outer compact() is needed
|
|
69
|
-
// (nesting it confused generic inference of `data`/`response`).
|
|
70
|
-
const response = await this.connection.call({
|
|
71
|
-
cmd: 'PUSH',
|
|
72
|
-
queue: step.queueName,
|
|
73
|
-
data,
|
|
74
|
-
...wireJobOptions(step.opts),
|
|
75
|
-
dependsOn: prevId ? [prevId] : undefined,
|
|
76
|
-
});
|
|
77
|
-
const id = String(response.id);
|
|
78
|
-
jobIds.push(id);
|
|
79
|
-
prevId = id;
|
|
80
|
-
}
|
|
81
|
-
return { jobIds };
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
await this.rollback(jobIds);
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/** Parallel jobs converging into a final fan-in job. */
|
|
89
|
-
async addBulkThen(parallel, final) {
|
|
90
|
-
const parallelIds = [];
|
|
91
|
-
try {
|
|
92
|
-
const results = await Promise.allSettled(parallel.map(async (step) => {
|
|
93
|
-
const response = await this.connection.call(compact({
|
|
94
|
-
cmd: 'PUSH',
|
|
95
|
-
queue: step.queueName,
|
|
96
|
-
data: jobPayload(step.name, step.data),
|
|
97
|
-
...wireJobOptions(step.opts),
|
|
98
|
-
}));
|
|
99
|
-
return String(response.id);
|
|
100
|
-
}));
|
|
101
|
-
const errors = [];
|
|
102
|
-
for (const r of results) {
|
|
103
|
-
if (r.status === 'fulfilled')
|
|
104
|
-
parallelIds.push(r.value);
|
|
105
|
-
else
|
|
106
|
-
errors.push(r.reason);
|
|
107
|
-
}
|
|
108
|
-
if (errors.length > 0) {
|
|
109
|
-
await this.rollback(parallelIds);
|
|
110
|
-
throw errors[0] instanceof Error ? errors[0] : new Error(String(errors[0]));
|
|
111
|
-
}
|
|
112
|
-
const finalData = {
|
|
113
|
-
...jobPayload(final.name, final.data),
|
|
114
|
-
__flowParentIds: parallelIds,
|
|
115
|
-
};
|
|
116
|
-
const finalId = await this.pushWithParent(final.queueName, finalData, final.opts, null, parallelIds);
|
|
117
|
-
return { parallelIds, finalId };
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
await this.rollback(parallelIds);
|
|
121
|
-
throw err;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
close() {
|
|
125
|
-
if (this.ownsConnection)
|
|
126
|
-
this.connection.close();
|
|
127
|
-
}
|
|
128
|
-
// ----------------------------------------------------------------- internals
|
|
129
|
-
async addNode(node, parentRef, created) {
|
|
130
|
-
const childNodes = [];
|
|
131
|
-
const childIds = [];
|
|
132
|
-
if (node.children && node.children.length > 0) {
|
|
133
|
-
const tempParent = { id: 'pending', queue: node.queueName };
|
|
134
|
-
const results = await Promise.all(node.children.map((child) => this.addNode(child, tempParent, created)));
|
|
135
|
-
for (const childNode of results) {
|
|
136
|
-
childNodes.push(childNode);
|
|
137
|
-
childIds.push(childNode.job.id);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const jobData = jobPayload(node.name, node.data);
|
|
141
|
-
if (parentRef) {
|
|
142
|
-
jobData.__parentId = parentRef.id;
|
|
143
|
-
jobData.__parentQueue = parentRef.queue;
|
|
144
|
-
}
|
|
145
|
-
if (childIds.length > 0)
|
|
146
|
-
jobData.__childrenIds = childIds;
|
|
147
|
-
const id = await this.pushWithParent(node.queueName, jobData, node.opts, parentRef, childIds);
|
|
148
|
-
created.push(id);
|
|
149
|
-
const job = new Job({ id, queue: node.queueName, data: jobData }, this.connection);
|
|
150
|
-
return { job, children: childNodes.length > 0 ? childNodes : undefined };
|
|
151
|
-
}
|
|
152
|
-
async pushWithParent(queue, data, opts, parentRef, childIds) {
|
|
153
|
-
const response = await this.connection.call(compact({
|
|
154
|
-
cmd: 'PUSH',
|
|
155
|
-
queue,
|
|
156
|
-
data,
|
|
157
|
-
...wireJobOptions(opts),
|
|
158
|
-
parentId: parentRef?.id,
|
|
159
|
-
childrenIds: childIds.length > 0 ? childIds : undefined,
|
|
160
|
-
dependsOn: childIds.length > 0 ? childIds : undefined,
|
|
161
|
-
}));
|
|
162
|
-
const parentJobId = String(response.id);
|
|
163
|
-
// fix up children with the real parent id (like the official client)
|
|
164
|
-
for (const childId of childIds) {
|
|
165
|
-
await this.connection.call({ cmd: 'UpdateParent', childId, parentId: parentJobId });
|
|
166
|
-
}
|
|
167
|
-
return parentJobId;
|
|
168
|
-
}
|
|
169
|
-
async fetchNode(id, depth, maxChildren, visited) {
|
|
170
|
-
if (visited.has(id))
|
|
171
|
-
return null; // cycle guard: id already on the current path
|
|
172
|
-
visited.add(id);
|
|
173
|
-
// A missing job — the root, or a child removed via removeOnComplete/cancel
|
|
174
|
-
// (childrenIds is a static push-time list, never pruned) — yields null and
|
|
175
|
-
// is skipped, returning the surviving partial tree instead of throwing.
|
|
176
|
-
let response;
|
|
177
|
-
try {
|
|
178
|
-
response = await this.connection.call({ cmd: 'GetJob', id });
|
|
179
|
-
}
|
|
180
|
-
catch (err) {
|
|
181
|
-
// Only 'Job not found' means a removed node; a real server error must not
|
|
182
|
-
// masquerade as a missing child and yield a misleading partial tree.
|
|
183
|
-
if (err instanceof CommandError && /not found/i.test(err.message))
|
|
184
|
-
return null;
|
|
185
|
-
throw err;
|
|
186
|
-
}
|
|
187
|
-
const raw = response.job;
|
|
188
|
-
if (!raw)
|
|
189
|
-
return null;
|
|
190
|
-
const job = new Job(raw, this.connection);
|
|
191
|
-
if (depth <= 0 || job.childrenIds.length === 0)
|
|
192
|
-
return { job };
|
|
193
|
-
const limit = maxChildren ?? job.childrenIds.length;
|
|
194
|
-
const children = [];
|
|
195
|
-
for (const childId of job.childrenIds.slice(0, limit)) {
|
|
196
|
-
const child = await this.fetchNode(childId, depth - 1, maxChildren, visited);
|
|
197
|
-
if (child)
|
|
198
|
-
children.push(child);
|
|
199
|
-
}
|
|
200
|
-
return { job, children: children.length > 0 ? children : undefined };
|
|
201
|
-
}
|
|
202
|
-
async rollback(jobIds) {
|
|
203
|
-
await Promise.all(jobIds.map(async (id) => {
|
|
204
|
-
try {
|
|
205
|
-
await this.connection.call({ cmd: 'Cancel', id });
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
// ignore cleanup errors
|
|
209
|
-
}
|
|
210
|
-
}));
|
|
211
|
-
}
|
|
212
|
-
}
|
package/dist/job.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Job wrapper: read view over the server job record + per-job operations.
|
|
3
|
-
* Mirrors the official TS client's Job surface (TCP mode).
|
|
4
|
-
*/
|
|
5
|
-
export class Job {
|
|
6
|
-
raw;
|
|
7
|
-
token;
|
|
8
|
-
conn;
|
|
9
|
-
onProgress;
|
|
10
|
-
constructor(raw, connection, token, onProgress) {
|
|
11
|
-
this.raw = raw;
|
|
12
|
-
this.conn = connection;
|
|
13
|
-
this.token = token;
|
|
14
|
-
this.onProgress = onProgress;
|
|
15
|
-
}
|
|
16
|
-
// ------------------------------------------------------------- properties
|
|
17
|
-
get id() {
|
|
18
|
-
return String(this.raw.id);
|
|
19
|
-
}
|
|
20
|
-
get queue() {
|
|
21
|
-
return String(this.raw.queue);
|
|
22
|
-
}
|
|
23
|
-
get data() {
|
|
24
|
-
return this.raw.data;
|
|
25
|
-
}
|
|
26
|
-
/** Job name (stored inside `data.name`, mirroring the official client). */
|
|
27
|
-
get name() {
|
|
28
|
-
const data = this.raw.data;
|
|
29
|
-
if (data && typeof data === 'object' && 'name' in data) {
|
|
30
|
-
const name = data.name;
|
|
31
|
-
return name === undefined || name === null ? undefined : String(name);
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
get priority() {
|
|
36
|
-
return Number(this.raw.priority ?? 0);
|
|
37
|
-
}
|
|
38
|
-
get attempts() {
|
|
39
|
-
return Number(this.raw.attempts ?? 0);
|
|
40
|
-
}
|
|
41
|
-
get maxAttempts() {
|
|
42
|
-
return Number(this.raw.maxAttempts ?? 0);
|
|
43
|
-
}
|
|
44
|
-
get createdAt() {
|
|
45
|
-
return this.raw.createdAt === undefined ? undefined : Number(this.raw.createdAt);
|
|
46
|
-
}
|
|
47
|
-
/** Creation time in epoch ms (BullMQ-parity alias of createdAt). */
|
|
48
|
-
get timestamp() {
|
|
49
|
-
return this.createdAt ?? Date.now();
|
|
50
|
-
}
|
|
51
|
-
get startedAt() {
|
|
52
|
-
return this.raw.startedAt === undefined || this.raw.startedAt === null
|
|
53
|
-
? null
|
|
54
|
-
: Number(this.raw.startedAt);
|
|
55
|
-
}
|
|
56
|
-
get completedAt() {
|
|
57
|
-
return this.raw.completedAt === undefined || this.raw.completedAt === null
|
|
58
|
-
? null
|
|
59
|
-
: Number(this.raw.completedAt);
|
|
60
|
-
}
|
|
61
|
-
get customId() {
|
|
62
|
-
return this.raw.customId === undefined || this.raw.customId === null
|
|
63
|
-
? null
|
|
64
|
-
: String(this.raw.customId);
|
|
65
|
-
}
|
|
66
|
-
get tags() {
|
|
67
|
-
return Array.isArray(this.raw.tags) ? this.raw.tags.map(String) : [];
|
|
68
|
-
}
|
|
69
|
-
get groupId() {
|
|
70
|
-
return this.raw.groupId === undefined || this.raw.groupId === null
|
|
71
|
-
? null
|
|
72
|
-
: String(this.raw.groupId);
|
|
73
|
-
}
|
|
74
|
-
get parentId() {
|
|
75
|
-
return this.raw.parentId === undefined || this.raw.parentId === null
|
|
76
|
-
? null
|
|
77
|
-
: String(this.raw.parentId);
|
|
78
|
-
}
|
|
79
|
-
get childrenIds() {
|
|
80
|
-
return Array.isArray(this.raw.childrenIds) ? this.raw.childrenIds.map(String) : [];
|
|
81
|
-
}
|
|
82
|
-
get dependsOn() {
|
|
83
|
-
return Array.isArray(this.raw.dependsOn) ? this.raw.dependsOn.map(String) : [];
|
|
84
|
-
}
|
|
85
|
-
get progress() {
|
|
86
|
-
return Number(this.raw.progress ?? 0);
|
|
87
|
-
}
|
|
88
|
-
get stacktrace() {
|
|
89
|
-
return Array.isArray(this.raw.stacktrace) ? this.raw.stacktrace.map(String) : null;
|
|
90
|
-
}
|
|
91
|
-
get state() {
|
|
92
|
-
return this.raw.state === undefined ? undefined : String(this.raw.state);
|
|
93
|
-
}
|
|
94
|
-
// ------------------------------------------------------------- operations
|
|
95
|
-
call(command) {
|
|
96
|
-
if (!this.conn)
|
|
97
|
-
return Promise.reject(new Error('Job is not bound to a connection'));
|
|
98
|
-
return this.conn.call(command);
|
|
99
|
-
}
|
|
100
|
-
/** Report processing progress (0-100) to the server. */
|
|
101
|
-
async updateProgress(progress, message) {
|
|
102
|
-
await this.call({ cmd: 'Progress', id: this.id, progress, message });
|
|
103
|
-
this.onProgress?.(this, progress);
|
|
104
|
-
}
|
|
105
|
-
/** Append a log row to the job. */
|
|
106
|
-
async log(message, level) {
|
|
107
|
-
await this.call({ cmd: 'AddLog', id: this.id, message, level });
|
|
108
|
-
}
|
|
109
|
-
/** Renew this job's lock (stall detection). */
|
|
110
|
-
async heartbeat() {
|
|
111
|
-
await this.call({ cmd: 'JobHeartbeat', id: this.id, token: this.token });
|
|
112
|
-
}
|
|
113
|
-
async extendLock(durationMs) {
|
|
114
|
-
await this.call({ cmd: 'ExtendLock', id: this.id, token: this.token, duration: durationMs });
|
|
115
|
-
}
|
|
116
|
-
async getState() {
|
|
117
|
-
const response = await this.call({ cmd: 'GetState', id: this.id });
|
|
118
|
-
return String(response.state);
|
|
119
|
-
}
|
|
120
|
-
async getChildrenValues() {
|
|
121
|
-
const response = await this.call({ cmd: 'GetChildrenValues', id: this.id });
|
|
122
|
-
const data = (response.data ?? {});
|
|
123
|
-
return (data.values ?? response.values ?? {});
|
|
124
|
-
}
|
|
125
|
-
async remove() {
|
|
126
|
-
await this.call({ cmd: 'Cancel', id: this.id });
|
|
127
|
-
}
|
|
128
|
-
async discard() {
|
|
129
|
-
await this.call({ cmd: 'Discard', id: this.id });
|
|
130
|
-
}
|
|
131
|
-
async promote() {
|
|
132
|
-
await this.call({ cmd: 'Promote', id: this.id });
|
|
133
|
-
}
|
|
134
|
-
/** failed → waiting (BullMQ contract; MoveToWait over TCP). */
|
|
135
|
-
async retry() {
|
|
136
|
-
await this.call({ cmd: 'MoveToWait', id: this.id });
|
|
137
|
-
}
|
|
138
|
-
async updateData(data) {
|
|
139
|
-
await this.call({ cmd: 'Update', id: this.id, data });
|
|
140
|
-
}
|
|
141
|
-
async changePriority(opts) {
|
|
142
|
-
await this.call({
|
|
143
|
-
cmd: 'ChangePriority',
|
|
144
|
-
id: this.id,
|
|
145
|
-
priority: opts.priority,
|
|
146
|
-
lifo: opts.lifo,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
async changeDelay(delayMs) {
|
|
150
|
-
await this.call({ cmd: 'ChangeDelay', id: this.id, delay: delayMs });
|
|
151
|
-
}
|
|
152
|
-
async moveToDelayed(delayMs) {
|
|
153
|
-
await this.call({ cmd: 'MoveToDelayed', id: this.id, delay: delayMs });
|
|
154
|
-
}
|
|
155
|
-
}
|
package/dist/observability.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Observability primitives: a pluggable structured logger and a telemetry
|
|
3
|
-
* sink. Zero hard dependencies — wire your own OpenTelemetry / Prometheus /
|
|
4
|
-
* logging stack through these interfaces. Defaults are no-ops, so the SDK is
|
|
5
|
-
* silent unless you opt in.
|
|
6
|
-
*/
|
|
7
|
-
/** Silent logger (the default). */
|
|
8
|
-
export const noopLogger = {
|
|
9
|
-
debug() { },
|
|
10
|
-
info() { },
|
|
11
|
-
warn() { },
|
|
12
|
-
error() { },
|
|
13
|
-
};
|
|
14
|
-
const LEVELS = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
15
|
-
/**
|
|
16
|
-
* A console-backed logger. Levels below `min` are dropped. Opt-in — pass it as
|
|
17
|
-
* `logger` when you want the SDK to log to the console.
|
|
18
|
-
*/
|
|
19
|
-
export function consoleLogger(min = 'info') {
|
|
20
|
-
const floor = LEVELS[min];
|
|
21
|
-
const line = (lvl, msg, meta) => {
|
|
22
|
-
if (LEVELS[lvl] < floor)
|
|
23
|
-
return;
|
|
24
|
-
const suffix = meta && Object.keys(meta).length > 0 ? ` ${JSON.stringify(meta)}` : '';
|
|
25
|
-
const sink = lvl === 'debug' ? console.log : console[lvl];
|
|
26
|
-
sink(`[bunqueue] ${lvl} ${msg}${suffix}`);
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
debug: (m, meta) => line('debug', m, meta),
|
|
30
|
-
info: (m, meta) => line('info', m, meta),
|
|
31
|
-
warn: (m, meta) => line('warn', m, meta),
|
|
32
|
-
error: (m, meta) => line('error', m, meta),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/** Lifecycle telemetry types that are ALSO emitted as EventEmitter events. */
|
|
36
|
-
export const LIFECYCLE_EVENTS = ['connect', 'disconnect', 'reconnect_scheduled'];
|
|
37
|
-
/** High-resolution monotonic clock (Node/Bun/Deno all expose `performance`). */
|
|
38
|
-
export const nowMs = () => performance.now();
|
|
39
|
-
/**
|
|
40
|
-
* Fans a telemetry event out to (1) the telemetry sink, (2) the logger, and
|
|
41
|
-
* (3) — for lifecycle events — the owning EventEmitter, so users can both
|
|
42
|
-
* scrape metrics and attach imperative `connection.on('connect', …)` handlers.
|
|
43
|
-
*/
|
|
44
|
-
export class Telemetry {
|
|
45
|
-
logger;
|
|
46
|
-
sink;
|
|
47
|
-
emit;
|
|
48
|
-
constructor(obs, emit) {
|
|
49
|
-
// Wrap the user logger so a throwing logger can never break the transport
|
|
50
|
-
// hot path (dispatch runs inside socket 'data' handlers and connect).
|
|
51
|
-
const inner = obs?.logger ?? noopLogger;
|
|
52
|
-
this.logger =
|
|
53
|
-
inner === noopLogger
|
|
54
|
-
? inner
|
|
55
|
-
: {
|
|
56
|
-
debug: (m, meta) => Telemetry.safely(() => inner.debug(m, meta)),
|
|
57
|
-
info: (m, meta) => Telemetry.safely(() => inner.info(m, meta)),
|
|
58
|
-
warn: (m, meta) => Telemetry.safely(() => inner.warn(m, meta)),
|
|
59
|
-
error: (m, meta) => Telemetry.safely(() => inner.error(m, meta)),
|
|
60
|
-
};
|
|
61
|
-
this.sink = obs?.onTelemetry;
|
|
62
|
-
this.emit = emit;
|
|
63
|
-
}
|
|
64
|
-
/** Observability must never break the client: swallow consumer errors. */
|
|
65
|
-
static safely(fn) {
|
|
66
|
-
try {
|
|
67
|
-
fn();
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
/* consumer logging/telemetry error — intentionally ignored */
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
get log() {
|
|
74
|
-
return this.logger;
|
|
75
|
-
}
|
|
76
|
-
/** Record a completed command's latency and outcome. */
|
|
77
|
-
command(cmd, reqId, startMs, ok) {
|
|
78
|
-
this.dispatch({ type: 'command', cmd, reqId, durationMs: nowMs() - startMs, ok });
|
|
79
|
-
}
|
|
80
|
-
timeout(cmd, reqId) {
|
|
81
|
-
this.logger.warn('command timed out', { cmd, reqId });
|
|
82
|
-
this.dispatch({ type: 'command_timeout', cmd, reqId });
|
|
83
|
-
}
|
|
84
|
-
connected(host, port, generation, startMs) {
|
|
85
|
-
this.logger.info('connected', { host, port, generation });
|
|
86
|
-
this.dispatch({ type: 'connect', host, port, generation, durationMs: nowMs() - startMs });
|
|
87
|
-
}
|
|
88
|
-
disconnected(host, port, generation) {
|
|
89
|
-
this.logger.info('disconnected', { host, port, generation });
|
|
90
|
-
this.dispatch({ type: 'disconnect', host, port, generation });
|
|
91
|
-
}
|
|
92
|
-
reconnectScheduled(host, port, attempt, delayMs) {
|
|
93
|
-
this.logger.warn('reconnect scheduled', { host, port, attempt, delayMs });
|
|
94
|
-
this.dispatch({ type: 'reconnect_scheduled', host, port, attempt, delayMs });
|
|
95
|
-
}
|
|
96
|
-
auth(ok) {
|
|
97
|
-
this.dispatch({ type: 'auth', ok });
|
|
98
|
-
}
|
|
99
|
-
backpressure(inFlight, maxInFlight) {
|
|
100
|
-
this.dispatch({ type: 'backpressure', inFlight, maxInFlight });
|
|
101
|
-
}
|
|
102
|
-
dispatch(event) {
|
|
103
|
-
// A throwing sink or lifecycle listener must never break the transport:
|
|
104
|
-
// dispatch runs inside socket 'data' handlers and the connect path.
|
|
105
|
-
Telemetry.safely(() => this.sink?.(event));
|
|
106
|
-
if (LIFECYCLE_EVENTS.includes(event.type)) {
|
|
107
|
-
Telemetry.safely(() => this.emit(event.type, event));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
package/dist/queue-admin.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue admin surface: DLQ, stall/DLQ configs, rate limits, schedulers,
|
|
3
|
-
* monitoring and webhooks. Merged onto Queue.prototype by queue.ts.
|
|
4
|
-
*/
|
|
5
|
-
import { CommandError } from './errors.js';
|
|
6
|
-
import { compact } from './frame.js';
|
|
7
|
-
import { jobPayload, wireJobOptions } from './types.js';
|
|
8
|
-
export const adminMethods = {
|
|
9
|
-
// ---------------------------------------------------------------------- dlq
|
|
10
|
-
async getDlq(count) {
|
|
11
|
-
const response = await this.call(compact({ cmd: 'Dlq', queue: this.name, count }));
|
|
12
|
-
return (response.jobs ?? response.data ?? []);
|
|
13
|
-
},
|
|
14
|
-
async retryDlq(jobId) {
|
|
15
|
-
const response = await this.call(compact({ cmd: 'RetryDlq', queue: this.name, jobId }));
|
|
16
|
-
return Number(response.count ?? 0);
|
|
17
|
-
},
|
|
18
|
-
async purgeDlq() {
|
|
19
|
-
const response = await this.call({ cmd: 'PurgeDlq', queue: this.name });
|
|
20
|
-
return Number(response.count ?? 0);
|
|
21
|
-
},
|
|
22
|
-
async setDlqConfig(config) {
|
|
23
|
-
await this.call({ cmd: 'SetDlqConfig', queue: this.name, config });
|
|
24
|
-
},
|
|
25
|
-
async getDlqConfig() {
|
|
26
|
-
const response = await this.call({ cmd: 'GetDlqConfig', queue: this.name });
|
|
27
|
-
return (response.config ?? response.data ?? {});
|
|
28
|
-
},
|
|
29
|
-
// -------------------------------------------------------------------- stall
|
|
30
|
-
async setStallConfig(config) {
|
|
31
|
-
await this.call({ cmd: 'SetStallConfig', queue: this.name, config });
|
|
32
|
-
},
|
|
33
|
-
async getStallConfig() {
|
|
34
|
-
const response = await this.call({ cmd: 'GetStallConfig', queue: this.name });
|
|
35
|
-
return (response.config ?? response.data ?? {});
|
|
36
|
-
},
|
|
37
|
-
// -------------------------------------------------- rate limit / concurrency
|
|
38
|
-
/** `duration` accepted for signature parity; the TCP wire carries only `limit`. */
|
|
39
|
-
async setGlobalRateLimit(max, _duration) {
|
|
40
|
-
await this.call({ cmd: 'RateLimit', queue: this.name, limit: max });
|
|
41
|
-
},
|
|
42
|
-
async removeGlobalRateLimit() {
|
|
43
|
-
await this.call({ cmd: 'RateLimitClear', queue: this.name });
|
|
44
|
-
},
|
|
45
|
-
async setGlobalConcurrency(concurrency) {
|
|
46
|
-
await this.call({ cmd: 'SetConcurrency', queue: this.name, limit: concurrency });
|
|
47
|
-
},
|
|
48
|
-
async removeGlobalConcurrency() {
|
|
49
|
-
await this.call({ cmd: 'ClearConcurrency', queue: this.name });
|
|
50
|
-
},
|
|
51
|
-
// ---------------------------------------------------------------- scheduler
|
|
52
|
-
/** Create/update a recurring job scheduler (cron pattern or fixed interval). */
|
|
53
|
-
async upsertJobScheduler(schedulerId, repeat, template = {}) {
|
|
54
|
-
// Priority and deduplication of spawned jobs travel as TOP-LEVEL Cron
|
|
55
|
-
// fields (the handler reads cmd.priority/uniqueKey/dedup); inside
|
|
56
|
-
// jobOptions the server's CronJobOptions silently ignores them.
|
|
57
|
-
const dedup = template.opts?.deduplication;
|
|
58
|
-
await this.call(compact({
|
|
59
|
-
cmd: 'Cron',
|
|
60
|
-
name: schedulerId,
|
|
61
|
-
queue: this.name,
|
|
62
|
-
data: jobPayload(template.name ?? schedulerId, template.data ?? {}),
|
|
63
|
-
schedule: repeat.pattern,
|
|
64
|
-
repeatEvery: repeat.every,
|
|
65
|
-
priority: template.opts?.priority,
|
|
66
|
-
timezone: repeat.tz,
|
|
67
|
-
immediately: repeat.immediately,
|
|
68
|
-
maxLimit: repeat.limit,
|
|
69
|
-
uniqueKey: dedup?.id,
|
|
70
|
-
dedup: dedup
|
|
71
|
-
? compact({ ttl: dedup.ttl, extend: dedup.extend, replace: dedup.replace })
|
|
72
|
-
: undefined,
|
|
73
|
-
skipMissedOnRestart: repeat.skipMissedOnRestart,
|
|
74
|
-
skipIfNoWorker: repeat.skipIfNoWorker,
|
|
75
|
-
preventOverlap: repeat.preventOverlap,
|
|
76
|
-
jobOptions: template.opts ? wireJobOptions(template.opts) : undefined,
|
|
77
|
-
}));
|
|
78
|
-
},
|
|
79
|
-
async removeJobScheduler(schedulerId) {
|
|
80
|
-
await this.call({ cmd: 'CronDelete', name: schedulerId });
|
|
81
|
-
},
|
|
82
|
-
async getJobScheduler(schedulerId) {
|
|
83
|
-
try {
|
|
84
|
-
const response = await this.call({ cmd: 'CronGet', name: schedulerId });
|
|
85
|
-
return (response.cron ?? response.data ?? null);
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
// Only 'Cron job not found' maps to null; connection loss, timeouts and
|
|
89
|
-
// real server errors must surface, not masquerade as a missing scheduler.
|
|
90
|
-
if (err instanceof CommandError && /not found/i.test(err.message))
|
|
91
|
-
return null;
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
async getJobSchedulers() {
|
|
96
|
-
const response = await this.call({ cmd: 'CronList' });
|
|
97
|
-
const crons = (response.crons ?? []);
|
|
98
|
-
return crons.filter((cron) => cron.queue === this.name);
|
|
99
|
-
},
|
|
100
|
-
async getJobSchedulersCount() {
|
|
101
|
-
return (await this.getJobSchedulers()).length;
|
|
102
|
-
},
|
|
103
|
-
/** Helper: run `name` on a cron `schedule`. */
|
|
104
|
-
addCron(name, schedule, data, opts) {
|
|
105
|
-
return this.upsertJobScheduler(name, { pattern: schedule }, { name, data, opts });
|
|
106
|
-
},
|
|
107
|
-
/** Helper: run `name` every `intervalMs` milliseconds. */
|
|
108
|
-
every(name, intervalMs, data, opts) {
|
|
109
|
-
return this.upsertJobScheduler(name, { every: intervalMs }, { name, data, opts });
|
|
110
|
-
},
|
|
111
|
-
// --------------------------------------------------------------- monitoring
|
|
112
|
-
async getWorkers() {
|
|
113
|
-
const response = await this.call({ cmd: 'ListWorkers' });
|
|
114
|
-
const data = (response.data ?? {});
|
|
115
|
-
return (data.workers ?? response.workers ?? []);
|
|
116
|
-
},
|
|
117
|
-
async getWorkersCount() {
|
|
118
|
-
return (await this.getWorkers()).length;
|
|
119
|
-
},
|
|
120
|
-
async getStats() {
|
|
121
|
-
const response = await this.call({ cmd: 'Stats' });
|
|
122
|
-
return (response.stats ?? {});
|
|
123
|
-
},
|
|
124
|
-
async getMetrics() {
|
|
125
|
-
const response = await this.call({ cmd: 'Metrics' });
|
|
126
|
-
return (response.metrics ?? {});
|
|
127
|
-
},
|
|
128
|
-
/** Server returns queue NAMES (strings). */
|
|
129
|
-
async listQueues() {
|
|
130
|
-
const response = await this.call({ cmd: 'ListQueues' });
|
|
131
|
-
const queues = (response.queues ?? []);
|
|
132
|
-
return queues.map((q) => (typeof q === 'string' ? q : String(q.name)));
|
|
133
|
-
},
|
|
134
|
-
// ----------------------------------------------------------------- webhooks
|
|
135
|
-
async addWebhook(opts) {
|
|
136
|
-
const response = await this.call(compact({
|
|
137
|
-
cmd: 'AddWebhook',
|
|
138
|
-
url: opts.url,
|
|
139
|
-
events: opts.events,
|
|
140
|
-
queue: opts.queue ?? this.name,
|
|
141
|
-
secret: opts.secret,
|
|
142
|
-
}));
|
|
143
|
-
const data = (response.data ?? {});
|
|
144
|
-
return (data.webhook ?? data);
|
|
145
|
-
},
|
|
146
|
-
async removeWebhook(webhookId) {
|
|
147
|
-
await this.call({ cmd: 'RemoveWebhook', webhookId });
|
|
148
|
-
},
|
|
149
|
-
async listWebhooks() {
|
|
150
|
-
const response = await this.call({ cmd: 'ListWebhooks' });
|
|
151
|
-
const data = (response.data ?? {});
|
|
152
|
-
return (data.webhooks ?? response.webhooks ?? []);
|
|
153
|
-
},
|
|
154
|
-
async setWebhookEnabled(webhookId, enabled) {
|
|
155
|
-
// wire field is `id` (SetWebhookEnabledCommand), unlike RemoveWebhook's `webhookId`
|
|
156
|
-
await this.call({ cmd: 'SetWebhookEnabled', id: webhookId, enabled });
|
|
157
|
-
},
|
|
158
|
-
};
|