bunqueue-client 0.1.9 → 0.2.0
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 +150 -0
- package/LEGACY.md +460 -0
- package/README.md +204 -349
- package/dist/ack-batcher.js +7 -67
- package/dist/canonical-manifest.json +930 -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 +16418 -0
- package/dist/frame.js +14 -57
- package/dist/index.d.ts +1 -27
- package/dist/index.js +10905 -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/clientTracking.d.ts +44 -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 +43 -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/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 +96 -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 +10 -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 +87 -0
- package/dist/types/src/application/types/contexts.d.ts +114 -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 +98 -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 +74 -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 +70 -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 +12 -0
- package/dist/types/src/domain/job/create.d.ts +2 -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 +4 -0
- package/dist/types/src/domain/job/payload.d.ts +18 -0
- package/dist/types/src/domain/job/state.d.ts +8 -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 +110 -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 +91 -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 +153 -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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface AckEntry {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
}
|
|
4
|
+
/** Parse structured ACKB evidence while preserving duplicate job-ID positions. */
|
|
5
|
+
export declare function ignoredAckIndices(data: unknown, batch: readonly AckEntry[]): ReadonlySet<number>;
|
|
6
|
+
/** Parse a single ACK/FAIL response; historical applied responses have no data. */
|
|
7
|
+
export declare function terminalOutcomeWasApplied(data: unknown): boolean;
|
|
8
|
+
export {};
|
|
@@ -59,8 +59,11 @@ export interface JobOptions {
|
|
|
59
59
|
}
|
|
60
60
|
/** Map SDK JobOptions to the PUSH/PUSHB wire fields (undefined keys dropped). */
|
|
61
61
|
export declare function wireJobOptions(opts?: JobOptions): Record<string, unknown>;
|
|
62
|
-
/**
|
|
63
|
-
export declare function jobPayload(name: string, data: unknown):
|
|
62
|
+
/** Build the protocol-owned name field without changing user data. */
|
|
63
|
+
export declare function jobPayload(name: string, data: unknown): {
|
|
64
|
+
name: string;
|
|
65
|
+
data: unknown;
|
|
66
|
+
};
|
|
64
67
|
export interface JobCounts {
|
|
65
68
|
waiting: number;
|
|
66
69
|
prioritized: number;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* dispatch shared by the Worker pull loop (worker.ts).
|
|
4
4
|
*/
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
6
|
-
import { Connection } from
|
|
7
|
-
import
|
|
6
|
+
import { Connection } from "./connection.js";
|
|
7
|
+
import type { Response } from "./connection-types.js";
|
|
8
|
+
import { type WorkerEventMap, type WorkerOptions } from "./worker-types.js";
|
|
8
9
|
export declare class WorkerBase<T = unknown, R = unknown> extends EventEmitter {
|
|
9
10
|
readonly queue: string;
|
|
10
11
|
readonly concurrency: number;
|
|
@@ -63,12 +64,11 @@ export declare class WorkerBase<T = unknown, R = unknown> extends EventEmitter {
|
|
|
63
64
|
* With `force` the wait for in-flight jobs is skipped (parity with the
|
|
64
65
|
* official client's `close(force)`). */
|
|
65
66
|
close(force?: boolean): Promise<void>;
|
|
66
|
-
/** Dispatch a command
|
|
67
|
-
*
|
|
68
|
-
* ('completed'/'failed' emits, counters) on it. */
|
|
67
|
+
/** Dispatch a command and route failures to 'error'. The optional outcome
|
|
68
|
+
* parser decides whether a successful response authorizes local effects. */
|
|
69
69
|
protected safeCall(command: Record<string, unknown> & {
|
|
70
70
|
cmd: string;
|
|
71
|
-
}): Promise<boolean>;
|
|
71
|
+
}, outcome?: (response: Response) => boolean): Promise<boolean>;
|
|
72
72
|
/** Hook run during close() before draining in-flight jobs (see Worker). */
|
|
73
73
|
protected beforeClose(): Promise<void>;
|
|
74
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Worker option types and shared constants. */
|
|
2
|
-
import type { TlsOption } from
|
|
3
|
-
import type { Job } from
|
|
4
|
-
import type { Observability } from
|
|
2
|
+
import type { TlsOption } from "./connection.js";
|
|
3
|
+
import type { Job } from "./job.js";
|
|
4
|
+
import type { Observability } from "./observability.js";
|
|
5
5
|
export type Processor<T = unknown, R = unknown> = (job: Job<T>) => R | Promise<R>;
|
|
6
6
|
/**
|
|
7
7
|
* Typed Worker event map: listeners registered via `on`/`once`/`off` for these
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* live in the bunqueue server — the worker pulls, heartbeats and acks/fails.
|
|
6
6
|
* Lifecycle state and cooperative cancel live in WorkerBase.
|
|
7
7
|
*/
|
|
8
|
-
import { WorkerBase } from
|
|
9
|
-
import { type Processor, type WorkerOptions } from
|
|
8
|
+
import { WorkerBase } from "./worker-base.js";
|
|
9
|
+
import { type Processor, type WorkerOptions } from "./worker-types.js";
|
|
10
10
|
export declare class Worker<T = unknown, R = unknown> extends WorkerBase<T, R> {
|
|
11
11
|
private readonly processor;
|
|
12
12
|
private readonly ackBatcher;
|
|
13
|
+
private readonly slotSignal;
|
|
13
14
|
constructor(queue: string, processor: Processor<T, R>, opts?: WorkerOptions);
|
|
14
15
|
/** Flush batched ACKs before the base class drains in-flight jobs. */
|
|
15
16
|
protected beforeClose(): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CronScheduler } from "../../infrastructure/scheduler/cronScheduler.js";
|
|
2
|
+
import type { BackgroundContext, BackgroundTaskHandles } from "../types/index.js";
|
|
3
|
+
export declare function startBackgroundTasks(ctx: BackgroundContext, cronScheduler: CronScheduler): BackgroundTaskHandles;
|
|
4
|
+
export declare function stopBackgroundTasks(handles: BackgroundTaskHandles): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type JobId } from "../../../domain/types/job.js";
|
|
2
|
+
import type { BackgroundContext } from "../../types/index.js";
|
|
3
|
+
export declare function restoreGroupPolicies(ctx: BackgroundContext, groupStates: ReturnType<NonNullable<BackgroundContext['storage']>['loadGroupState']>): void;
|
|
4
|
+
export declare function restoreRecoveryPolicies(ctx: BackgroundContext, queueStates: ReturnType<NonNullable<BackgroundContext['storage']>['loadQueueState']>): void;
|
|
5
|
+
export declare function recoverActiveJobs(ctx: BackgroundContext, dlqJobIds: Set<JobId>, now: number): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BackgroundContext } from "../../types/index.js";
|
|
2
|
+
import { type QueueStateRecord } from "./shared.js";
|
|
3
|
+
export declare function restoreDlq(ctx: BackgroundContext): void;
|
|
4
|
+
export declare function restoreQueueState(ctx: BackgroundContext, queueStates: QueueStateRecord[]): void;
|
|
5
|
+
export declare function recoverCompletedJobs(ctx: BackgroundContext): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Job } from "../../../domain/types/job.js";
|
|
2
|
+
import type { BackgroundContext } from "../../types/index.js";
|
|
3
|
+
export declare const RECOVERY_BATCH_SIZE = 10000;
|
|
4
|
+
export type RecoveryStorage = NonNullable<BackgroundContext['storage']>;
|
|
5
|
+
export type QueueStateRecord = ReturnType<RecoveryStorage['loadQueueState']>[number];
|
|
6
|
+
export declare function quarantineCorruptDependsOn(ctx: BackgroundContext, job: Job): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Job, JobId } from "../../domain/types/job.js";
|
|
2
|
+
import type { BackgroundContext } from "../types/index.js";
|
|
3
|
+
export declare const MAX_TIMER_DELAY_MS = 2147483647;
|
|
4
|
+
export declare function timeoutTimerDelay(deadline: number, now?: number): number;
|
|
5
|
+
/** Compatibility entry point for explicit timeout checks in tests and tooling. */
|
|
6
|
+
export declare function checkJobTimeouts(ctx: BackgroundContext): Promise<void>;
|
|
7
|
+
/** One timer tracks the earliest active processing deadline. */
|
|
8
|
+
export declare class JobTimeoutScheduler {
|
|
9
|
+
private readonly active;
|
|
10
|
+
private readonly deadlines;
|
|
11
|
+
private timer;
|
|
12
|
+
private armedDeadline;
|
|
13
|
+
private stopped;
|
|
14
|
+
private ctx;
|
|
15
|
+
get pendingCount(): number;
|
|
16
|
+
start(ctx: BackgroundContext): void;
|
|
17
|
+
schedule(job: Job): void;
|
|
18
|
+
cancel(jobId: JobId): void;
|
|
19
|
+
stop(): void;
|
|
20
|
+
private isCurrent;
|
|
21
|
+
private pruneStaleRoots;
|
|
22
|
+
private maybeCompact;
|
|
23
|
+
private armNext;
|
|
24
|
+
private expireDue;
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Stable background-task import surface. */
|
|
2
|
+
export { startBackgroundTasks, stopBackgroundTasks } from "./background/lifecycle.js";
|
|
3
|
+
export { recover } from "./background/recovery/index.js";
|
|
4
|
+
export { checkJobTimeouts } from "./background/timeouts.js";
|
|
5
|
+
export { processPendingDependencies } from "./dependencyProcessor.js";
|
|
6
|
+
export { getTaskErrorStats } from "./taskErrorTracking.js";
|
|
7
|
+
export type { BackgroundTaskHandles } from "./types/background.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleanup Tasks - Periodic maintenance and garbage collection
|
|
3
|
+
* Handles orphaned entries, stale data, and memory management
|
|
4
|
+
*/
|
|
5
|
+
import type { BackgroundContext } from "./types/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Main cleanup function - called periodically to maintain system health
|
|
8
|
+
* Cleans orphaned entries, stale data, and manages memory
|
|
9
|
+
*/
|
|
10
|
+
export declare function cleanup(ctx: BackgroundContext): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client Tracking - Client-job relationship management
|
|
3
|
+
* Handles job ownership and release on client disconnect
|
|
4
|
+
*/
|
|
5
|
+
import type { JobId } from "../domain/types/job.js";
|
|
6
|
+
import type { LockContext } from "./types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Register a job as owned by a client (called on PULL).
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerClientJob(clientId: string, jobId: JobId, ctx: LockContext): void;
|
|
11
|
+
/**
|
|
12
|
+
* Unregister a job from a client (called on ACK/FAIL).
|
|
13
|
+
*/
|
|
14
|
+
export declare function unregisterClientJob(clientId: string | undefined, jobId: JobId, ctx: LockContext): void;
|
|
15
|
+
/**
|
|
16
|
+
* Release all jobs owned by a client back to queue (called on TCP disconnect).
|
|
17
|
+
* Returns the number of jobs released.
|
|
18
|
+
*
|
|
19
|
+
* Uses proper locking to prevent race conditions.
|
|
20
|
+
*/
|
|
21
|
+
export declare function releaseClientJobs(clientId: string, ctx: LockContext): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Force-release client tracking without acquiring queue locks.
|
|
24
|
+
* Used as a last-resort fallback when releaseClientJobs has exhausted its
|
|
25
|
+
* retry budget (e.g. persistent lock contention on TCP disconnect). For each
|
|
26
|
+
* orphaned job:
|
|
27
|
+
* - clears `jobLocks` so a stale lock token can't survive the disconnect
|
|
28
|
+
* until its TTL expires;
|
|
29
|
+
* - expires both `lastHeartbeat` (so stall detection's heartbeat check
|
|
30
|
+
* fires) and `startedAt` (so the gracePeriod check passes immediately).
|
|
31
|
+
*
|
|
32
|
+
* Recovery latency: stall detection uses two-phase confirmation
|
|
33
|
+
* (stalledCandidates collected on one tick, acted on the next), so a job is
|
|
34
|
+
* recovered within ~2 stall-check ticks (≈10s with defaults). This is faster
|
|
35
|
+
* than the full stallTimeout (30s default) but NOT instant.
|
|
36
|
+
*
|
|
37
|
+
* This path runs lock-free: callers must accept that another path (stall
|
|
38
|
+
* detector, lock expiration) may concurrently mutate or remove the same job
|
|
39
|
+
* from processingShards. Worst case: our mutation lands on an object that is
|
|
40
|
+
* no longer in the Map, wasting the write. Never corrupts state.
|
|
41
|
+
*
|
|
42
|
+
* Returns the number of jobs whose state was reset.
|
|
43
|
+
*/
|
|
44
|
+
export declare function forceReleaseClientJobs(clientId: string, ctx: LockContext): number;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Job, JobId } from "../domain/types/job.js";
|
|
2
|
+
import type { SqliteStorage } from "../infrastructure/persistence/sqlite.js";
|
|
3
|
+
import type { DependencyResultTracker } from "./dependencyResultTracker.js";
|
|
4
|
+
export interface CompletedCleanupContext {
|
|
5
|
+
jobIndex: Map<JobId, {
|
|
6
|
+
type: string;
|
|
7
|
+
queueName?: string;
|
|
8
|
+
}>;
|
|
9
|
+
completedJobs: {
|
|
10
|
+
delete(jobId: JobId): boolean;
|
|
11
|
+
};
|
|
12
|
+
completedJobsData: {
|
|
13
|
+
get(jobId: JobId): Job | undefined;
|
|
14
|
+
delete(jobId: JobId): boolean;
|
|
15
|
+
};
|
|
16
|
+
jobResults?: {
|
|
17
|
+
delete(jobId: JobId): boolean;
|
|
18
|
+
};
|
|
19
|
+
jobResultQueues?: {
|
|
20
|
+
get(jobId: JobId): string | undefined;
|
|
21
|
+
delete(jobId: JobId): boolean;
|
|
22
|
+
};
|
|
23
|
+
jobLogs?: {
|
|
24
|
+
delete(jobId: JobId): boolean;
|
|
25
|
+
};
|
|
26
|
+
jobLogQueues?: {
|
|
27
|
+
get(jobId: JobId): string | undefined;
|
|
28
|
+
delete(jobId: JobId): boolean;
|
|
29
|
+
};
|
|
30
|
+
dependencyResults: DependencyResultTracker;
|
|
31
|
+
storage: SqliteStorage | null;
|
|
32
|
+
}
|
|
33
|
+
/** Delete completed rows first, then converge every bounded in-memory projection. */
|
|
34
|
+
export declare function cleanCompletedJobs(queue: string | null, completedBefore: number, limit: number, ctx: CompletedCleanupContext): JobId[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Job, type JobId } from "../domain/types/job.js";
|
|
2
|
+
import type { DlqContext } from "./dlqManager.js";
|
|
3
|
+
/** Completed-job retry state shared by embedded control surfaces. */
|
|
4
|
+
export interface RetryCompletedContext extends DlqContext {
|
|
5
|
+
completedJobs: {
|
|
6
|
+
has(id: JobId): boolean;
|
|
7
|
+
delete(id: JobId): boolean;
|
|
8
|
+
} & Iterable<JobId>;
|
|
9
|
+
completedJobsData: {
|
|
10
|
+
get(id: JobId): Job | undefined;
|
|
11
|
+
delete(id: JobId): boolean;
|
|
12
|
+
};
|
|
13
|
+
jobResults: {
|
|
14
|
+
delete(id: JobId): boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Retry a selected completed generation or an oldest-first bounded set. */
|
|
18
|
+
export declare function retryCompletedJobs(queue: string, ctx: RetryCompletedContext, targetId?: JobId, options?: {
|
|
19
|
+
limit?: number;
|
|
20
|
+
timestamp?: number;
|
|
21
|
+
}): number;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextFactory - Builds context objects for delegated operations
|
|
3
|
+
*/
|
|
4
|
+
import type { LockContext, BackgroundContext, StatsContext } from "./types/index.js";
|
|
5
|
+
import type { PushContext } from "./operations/push.js";
|
|
6
|
+
import type { PullContext } from "./operations/pull.js";
|
|
7
|
+
import type { AckContext } from "./operations/ack.js";
|
|
8
|
+
import type { JobManagementContext } from "./operations/jobManagement.js";
|
|
9
|
+
import type { QueryContext } from "./operations/queryOperations.js";
|
|
10
|
+
import type { DlqContext, RetryCompletedContext } from "./dlqManager.js";
|
|
11
|
+
import type { ContextCallbacks, ContextDependencies } from "./types/contextFactory.js";
|
|
12
|
+
export type { ContextCallbacks, ContextDependencies } from "./types/contextFactory.js";
|
|
13
|
+
/**
|
|
14
|
+
* Factory for building context objects
|
|
15
|
+
*/
|
|
16
|
+
export declare class ContextFactory {
|
|
17
|
+
private readonly deps;
|
|
18
|
+
private readonly callbacks;
|
|
19
|
+
constructor(deps: ContextDependencies, callbacks: ContextCallbacks);
|
|
20
|
+
getLockContext(): LockContext;
|
|
21
|
+
getBackgroundContext(): BackgroundContext;
|
|
22
|
+
getStatsContext(): StatsContext;
|
|
23
|
+
getPushContext(): PushContext;
|
|
24
|
+
getPullContext(): PullContext;
|
|
25
|
+
getAckContext(): AckContext;
|
|
26
|
+
getJobMgmtContext(): JobManagementContext;
|
|
27
|
+
getQueryContext(): QueryContext;
|
|
28
|
+
getDlqContext(): DlqContext;
|
|
29
|
+
getRetryCompletedContext(): RetryCompletedContext;
|
|
30
|
+
getLogsContext(): {
|
|
31
|
+
jobIndex: Map<import("../domain/types/job.js").JobId, import("../domain/types/queue.js").JobLocation>;
|
|
32
|
+
jobLogs: import("../shared/lruMap.js").LRUMap<import("../domain/types/job.js").JobId, import("../domain/types/worker.js").JobLogEntry[]>;
|
|
33
|
+
jobLogQueues: Map<import("../domain/types/job.js").JobId, string>;
|
|
34
|
+
maxLogsPerJob: number;
|
|
35
|
+
};
|
|
36
|
+
getQueueControlContext(): {
|
|
37
|
+
shards: import("../domain/queue/shard.js").Shard[];
|
|
38
|
+
jobIndex: Map<import("../domain/types/job.js").JobId, import("../domain/types/queue.js").JobLocation>;
|
|
39
|
+
processingShards: Map<import("../domain/types/job.js").JobId, import("../domain/types/job.js").Job>[];
|
|
40
|
+
completedJobs: import("../shared/boundedSet.js").BoundedSet<import("../domain/types/job.js").JobId>;
|
|
41
|
+
completedJobsData: import("../shared/boundedMap.js").BoundedMap<import("../domain/types/job.js").JobId, import("../domain/types/job.js").Job>;
|
|
42
|
+
jobResults: import("../shared/lruMap.js").LRUMap<import("../domain/types/job.js").JobId, unknown>;
|
|
43
|
+
jobResultQueues: Map<import("../domain/types/job.js").JobId, string>;
|
|
44
|
+
dependencyResults: import("./dependencyResultTracker.js").DependencyResultTracker;
|
|
45
|
+
jobLogs: import("../shared/lruMap.js").LRUMap<import("../domain/types/job.js").JobId, import("../domain/types/worker.js").JobLogEntry[]>;
|
|
46
|
+
jobLogQueues: Map<import("../domain/types/job.js").JobId, string>;
|
|
47
|
+
storage: import("../infrastructure/persistence/index.js").SqliteStorage | null;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Job, JobId } from "../domain/types/job.js";
|
|
2
|
+
import type { Shard } from "../domain/queue/shard.js";
|
|
3
|
+
import type { SqliteStorage } from "../infrastructure/persistence/sqlite.js";
|
|
4
|
+
import type { SetLike } from "../shared/lru.js";
|
|
5
|
+
interface CompletionRecord {
|
|
6
|
+
jobId: JobId;
|
|
7
|
+
queue: string;
|
|
8
|
+
pinned: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Payload-free completion evidence has two retention classes:
|
|
12
|
+
* recent IDs are FIFO-bounded, while IDs referenced by live dependency edges
|
|
13
|
+
* stay pinned until their final consumer is durably resolved or removed.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DependencyCompletionTracker implements SetLike<JobId> {
|
|
16
|
+
private readonly onRecentEvict?;
|
|
17
|
+
private readonly recent;
|
|
18
|
+
private recentOrder;
|
|
19
|
+
private recentOrderTokens;
|
|
20
|
+
private readonly recentTokens;
|
|
21
|
+
private recentOrderHead;
|
|
22
|
+
private nextRecentToken;
|
|
23
|
+
private readonly pinned;
|
|
24
|
+
private readonly owners;
|
|
25
|
+
private readonly maxRecent;
|
|
26
|
+
constructor(maxRecent: number, onRecentEvict?: ((jobId: JobId) => void) | undefined);
|
|
27
|
+
add(jobId: JobId, queue?: string): void;
|
|
28
|
+
pin(jobId: JobId, queue?: string): void;
|
|
29
|
+
unpin(jobId: JobId, retainAsRecent: boolean): void;
|
|
30
|
+
hydrate(records: Iterable<CompletionRecord>): void;
|
|
31
|
+
pinnedValues(): IterableIterator<JobId>;
|
|
32
|
+
has(jobId: JobId): boolean;
|
|
33
|
+
delete(jobId: JobId): boolean;
|
|
34
|
+
deleteForQueue(queue: string): JobId[];
|
|
35
|
+
clear(): void;
|
|
36
|
+
get size(): number;
|
|
37
|
+
private evictOldestRecent;
|
|
38
|
+
private compactRecentOrder;
|
|
39
|
+
}
|
|
40
|
+
export interface DependencyCompletionContext {
|
|
41
|
+
storage: SqliteStorage | null;
|
|
42
|
+
shards: Shard[];
|
|
43
|
+
depCompletions?: DependencyCompletionTracker;
|
|
44
|
+
maxDependencyCompletions: number;
|
|
45
|
+
}
|
|
46
|
+
export declare function hasDependencyWaiters(shards: Shard[], jobId: JobId): boolean;
|
|
47
|
+
/** Persist a removeOnComplete transition before publishing its RAM evidence. */
|
|
48
|
+
export declare function commitRemovedCompletion(job: Pick<Job, 'id' | 'queue'>, ctx: DependencyCompletionContext, completedAt?: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* Protect recent proofs when a newly accepted parent waits on another
|
|
51
|
+
* dependency. SQLite is updated first so RAM never advertises a stronger
|
|
52
|
+
* durability guarantee than the database.
|
|
53
|
+
*/
|
|
54
|
+
export declare function pinReferencedCompletions(dependencyIds: Iterable<JobId>, ctx: Pick<DependencyCompletionContext, 'storage' | 'depCompletions'>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Unpin candidates only after every shard has released its reverse edge.
|
|
57
|
+
* Storage returns the complete retained set because pruning can also evict
|
|
58
|
+
* older recent entries; hydrating from it keeps both RAM tiers exact.
|
|
59
|
+
*/
|
|
60
|
+
export declare function releaseDependencyCompletionPins(dependencyIds: Iterable<JobId>, ctx: DependencyCompletionContext): void;
|
|
61
|
+
/** Rebuild pin ownership from the authoritative reverse dependency indexes. */
|
|
62
|
+
export declare function reconcileDependencyCompletionPins(ctx: DependencyCompletionContext): void;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Processor - Job dependency resolution
|
|
3
|
+
* Uses reverse index for O(m) where m = jobs waiting on completed deps
|
|
4
|
+
*/
|
|
5
|
+
import type { Job } from "../domain/types/job.js";
|
|
6
|
+
import type { BackgroundContext } from "./types/index.js";
|
|
7
|
+
type DependencyReadyState = 'delayed' | 'prioritized' | 'waiting';
|
|
8
|
+
export declare function dependencyReadyState(job: Job, now: number): DependencyReadyState;
|
|
9
|
+
export declare function checkpointDependencyPromotion(job: Job, state: DependencyReadyState, now: number, storage: BackgroundContext['storage']): void;
|
|
10
|
+
/**
|
|
11
|
+
* Process pending dependency checks
|
|
12
|
+
* Resolves jobs whose dependencies have been completed
|
|
13
|
+
*/
|
|
14
|
+
export declare function processPendingDependencies(ctx: BackgroundContext): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JobId } from "../domain/types/job.js";
|
|
2
|
+
/**
|
|
3
|
+
* Retains results while at least one live dependency consumer may still read
|
|
4
|
+
* them. Ordinary completed-job results remain governed by the configured LRU.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DependencyResultTracker {
|
|
7
|
+
private readonly consumersByDependency;
|
|
8
|
+
private readonly dependenciesByConsumer;
|
|
9
|
+
private readonly protectedResults;
|
|
10
|
+
registerConsumer(consumerId: JobId, dependencyIds: readonly JobId[]): void;
|
|
11
|
+
retain(dependencyId: JobId, result: unknown): void;
|
|
12
|
+
has(dependencyId: JobId): boolean;
|
|
13
|
+
get(dependencyId: JobId): unknown;
|
|
14
|
+
hasConsumers(dependencyId: JobId): boolean;
|
|
15
|
+
releaseConsumer(consumerId: JobId): void;
|
|
16
|
+
releaseDependency(consumerId: JobId, dependencyId: JobId): void;
|
|
17
|
+
clear(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced DLQ Manager
|
|
3
|
+
* Dead Letter Queue operations with auto-retry, metadata, and lifecycle management
|
|
4
|
+
*/
|
|
5
|
+
import type { Job, JobId } from "../domain/types/job.js";
|
|
6
|
+
import type { JobLocation } from "../domain/types/queue.js";
|
|
7
|
+
import type { Shard } from "../domain/queue/shard.js";
|
|
8
|
+
import type { DlqEntry, DlqConfig, DlqFilter, DlqStats } from "../domain/types/dlq.js";
|
|
9
|
+
import type { SqliteStorage } from "../infrastructure/persistence/sqlite.js";
|
|
10
|
+
/** Context for DLQ operations */
|
|
11
|
+
export interface DlqContext {
|
|
12
|
+
shards: Shard[];
|
|
13
|
+
jobIndex: Map<JobId, JobLocation>;
|
|
14
|
+
jobResults: {
|
|
15
|
+
delete(id: JobId): boolean;
|
|
16
|
+
};
|
|
17
|
+
jobResultQueues: Map<JobId, string>;
|
|
18
|
+
dependencyResults: {
|
|
19
|
+
releaseConsumer(id: JobId): void;
|
|
20
|
+
};
|
|
21
|
+
customIdMap: {
|
|
22
|
+
get(id: string): JobId | undefined;
|
|
23
|
+
set(id: string, jobId: JobId): void;
|
|
24
|
+
delete(id: string): boolean;
|
|
25
|
+
};
|
|
26
|
+
jobLogs: {
|
|
27
|
+
delete(id: JobId): boolean;
|
|
28
|
+
};
|
|
29
|
+
jobLogQueues: Map<JobId, string>;
|
|
30
|
+
storage: SqliteStorage | null;
|
|
31
|
+
}
|
|
32
|
+
export { processAutoRetry, retryDlqByFilter, retryDlqJob, retryDlqJobs } from "./dlqRetry.js";
|
|
33
|
+
export { retryCompletedJobs, type RetryCompletedContext } from "./completedRetry.js";
|
|
34
|
+
/** Get jobs from DLQ (backward compatible) */
|
|
35
|
+
export declare function getDlqJobs(queue: string, ctx: DlqContext, count?: number): Job[];
|
|
36
|
+
/** Get DLQ entries with full metadata */
|
|
37
|
+
export declare function getDlqEntries(queue: string, ctx: DlqContext, filter?: DlqFilter): DlqEntry[];
|
|
38
|
+
/** Get DLQ statistics */
|
|
39
|
+
export declare function getDlqStats(queue: string, ctx: DlqContext): DlqStats;
|
|
40
|
+
/** Purge expired entries from DLQ */
|
|
41
|
+
export declare function purgeExpiredDlq(queue: string, ctx: DlqContext): number;
|
|
42
|
+
/** Purge all jobs from DLQ */
|
|
43
|
+
export declare function purgeDlqJobs(queue: string, ctx: DlqContext): number;
|
|
44
|
+
/** Remove one DLQ entry without re-enqueuing it. */
|
|
45
|
+
export declare function removeDlqJob(queue: string, id: JobId, ctx: DlqContext): boolean;
|
|
46
|
+
/** Configure DLQ for a queue */
|
|
47
|
+
export declare function configureDlq(queue: string, ctx: DlqContext, config: Partial<DlqConfig>): void;
|
|
48
|
+
/** Get DLQ configuration */
|
|
49
|
+
export declare function getDlqConfig(queue: string, ctx: DlqContext): DlqConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** DLQ manual and automatic retry transitions. */
|
|
2
|
+
import { type Job, type JobId } from "../domain/types/job.js";
|
|
3
|
+
import type { DlqFilter } from "../domain/types/dlq.js";
|
|
4
|
+
import type { DlqContext } from "./dlqManager.js";
|
|
5
|
+
/** Retry a single job from DLQ and reset the automatic retry generation. */
|
|
6
|
+
export declare function retryDlqJob(queue: string, jobId: JobId, ctx: DlqContext): Job | null;
|
|
7
|
+
/** Retry jobs from DLQ, optionally bounded to the oldest `limit` entries. */
|
|
8
|
+
export declare function retryDlqJobs(queue: string, ctx: DlqContext, jobId?: JobId, limit?: number): number;
|
|
9
|
+
/** Retry all DLQ entries selected by a metadata filter. */
|
|
10
|
+
export declare function retryDlqByFilter(queue: string, ctx: DlqContext, filter: DlqFilter): number;
|
|
11
|
+
/** Dispatch due auto-retries while preserving their bounded retry chain. */
|
|
12
|
+
export declare function processAutoRetry(queue: string, ctx: DlqContext): number;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events Manager
|
|
3
|
+
* Job event subscription and broadcasting
|
|
4
|
+
*/
|
|
5
|
+
import type { JobId } from "../domain/types/job.js";
|
|
6
|
+
import { EventType, type JobEvent } from "../domain/types/queue.js";
|
|
7
|
+
import type { WebhookManager } from "./webhookManager.js";
|
|
8
|
+
/** Event subscriber callback */
|
|
9
|
+
export type EventSubscriber = (event: JobEvent) => void;
|
|
10
|
+
export type EventBatchSubscriber = (events: readonly JobEvent[]) => void;
|
|
11
|
+
/** Events manager class */
|
|
12
|
+
export declare class EventsManager {
|
|
13
|
+
private readonly webhookManager;
|
|
14
|
+
/** Use Set for O(1) subscribe/unsubscribe instead of indexOf+splice */
|
|
15
|
+
private readonly subscribers;
|
|
16
|
+
/** Optional batch path for internal subscribers such as durable telemetry. */
|
|
17
|
+
private readonly batchSubscribers;
|
|
18
|
+
/** Waiters for specific job completions - for efficient WaitJob implementation */
|
|
19
|
+
private readonly completionWaiters;
|
|
20
|
+
constructor(webhookManager: WebhookManager);
|
|
21
|
+
/** Number of active event subscribers */
|
|
22
|
+
get subscriberCount(): number;
|
|
23
|
+
/** Number of jobs with active completion waiters */
|
|
24
|
+
get completionWaiterCount(): number;
|
|
25
|
+
/** Subscribe to job events - O(1) add and remove */
|
|
26
|
+
subscribe(callback: EventSubscriber, batchCallback?: EventBatchSubscriber): () => void;
|
|
27
|
+
/** Clear all subscribers (for shutdown) */
|
|
28
|
+
clear(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Wait for a specific job to complete - event-driven, no polling
|
|
31
|
+
* Returns true if job completed, false if timeout
|
|
32
|
+
*/
|
|
33
|
+
waitForJobCompletion(jobId: JobId, timeoutMs: number, signal?: AbortSignal): Promise<boolean>;
|
|
34
|
+
/** Check if broadcast has any listeners - for batch optimizations */
|
|
35
|
+
needsBroadcast(): boolean;
|
|
36
|
+
/** Broadcast event to all subscribers - optimized to skip work when no listeners */
|
|
37
|
+
broadcast(event: Partial<JobEvent> & {
|
|
38
|
+
eventType: EventType;
|
|
39
|
+
queue: string;
|
|
40
|
+
jobId: JobId;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
error?: string;
|
|
43
|
+
}): void;
|
|
44
|
+
/** Broadcast an ordered batch while allowing internal subscribers to persist once. */
|
|
45
|
+
broadcastBatch(events: readonly JobEvent[]): void;
|
|
46
|
+
private notifyCompletionWaiters;
|
|
47
|
+
private triggerWebhook;
|
|
48
|
+
/** Map internal event type to webhook event */
|
|
49
|
+
private mapEventToWebhook;
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JobId } from "../domain/types/job.js";
|
|
2
|
+
import type { JobLocation } from "../domain/types/queue.js";
|
|
3
|
+
import type { Shard } from "../domain/queue/shard.js";
|
|
4
|
+
import type { SqliteStorage } from "../infrastructure/persistence/sqlite.js";
|
|
5
|
+
import type { SetLike } from "../shared/lru.js";
|
|
6
|
+
import type { DependencyResultTracker } from "./dependencyResultTracker.js";
|
|
7
|
+
import { type DependencyCompletionTracker } from "./dependencyCompletions.js";
|
|
8
|
+
export interface FlowFailureRecoveryContext {
|
|
9
|
+
readonly storage: SqliteStorage;
|
|
10
|
+
readonly shards: Shard[];
|
|
11
|
+
readonly jobIndex: Map<JobId, JobLocation>;
|
|
12
|
+
readonly completedJobs: SetLike<JobId>;
|
|
13
|
+
readonly depCompletions?: DependencyCompletionTracker;
|
|
14
|
+
readonly maxDependencyCompletions: number;
|
|
15
|
+
readonly dependencyResults: DependencyResultTracker;
|
|
16
|
+
readonly failedChildrenValues: Map<JobId, Record<string, string>>;
|
|
17
|
+
readonly ignoredChildrenFailures: Map<JobId, Record<string, string>>;
|
|
18
|
+
}
|
|
19
|
+
/** Replay the durable flow-failure outbox before workers can observe recovered jobs. */
|
|
20
|
+
export declare function recoverFlowFailures(ctx: FlowFailureRecoveryContext): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Job, JobId } from "../domain/types/job.js";
|
|
2
|
+
import type { JobLocation } from "../domain/types/queue.js";
|
|
3
|
+
import type { Shard } from "../domain/queue/shard.js";
|
|
4
|
+
import type { SqliteStorage } from "../infrastructure/persistence/sqlite.js";
|
|
5
|
+
import type { RWLock } from "../shared/lock.js";
|
|
6
|
+
import type { MapLike, SetLike } from "../shared/lru.js";
|
|
7
|
+
export interface FlowParentBackpatchContext {
|
|
8
|
+
readonly storage: SqliteStorage | null;
|
|
9
|
+
readonly customIdLock: RWLock;
|
|
10
|
+
readonly shards: Shard[];
|
|
11
|
+
readonly shardLocks: RWLock[];
|
|
12
|
+
readonly processingShards: Map<JobId, Job>[];
|
|
13
|
+
readonly processingLocks: RWLock[];
|
|
14
|
+
readonly jobIndex: Map<JobId, JobLocation>;
|
|
15
|
+
readonly completedJobsData: MapLike<JobId, Job>;
|
|
16
|
+
readonly depCompletions: SetLike<JobId>;
|
|
17
|
+
}
|
|
18
|
+
/** Reject a backpatch that would steal a child from an existing real parent. */
|
|
19
|
+
export declare function assertFlowParentOwnership(child: Job, parentId: JobId): void;
|
|
20
|
+
export declare function isDeclaredFlowChild(parent: Job, childId: JobId): boolean;
|
|
21
|
+
export declare function canAcceptRemovedFlowChild(parent: Job | null, childId: JobId, depCompletions: SetLike<JobId>): boolean;
|
|
22
|
+
export declare function flowChildFailureError(child: Job, shards: Shard[]): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Replace the legacy `pending` parent marker for an edge already declared by
|
|
25
|
+
* the parent. This operation never changes parent scheduling or terminal state.
|
|
26
|
+
*/
|
|
27
|
+
export declare function backpatchDeclaredFlowChild(child: Job, parent: Job, ctx: FlowParentBackpatchContext): Promise<Job>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Job Logs Manager
|
|
3
|
+
* Per-job logging operations
|
|
4
|
+
*/
|
|
5
|
+
import type { JobId } from "../domain/types/job.js";
|
|
6
|
+
import { type JobLogEntry } from "../domain/types/worker.js";
|
|
7
|
+
import type { JobLocation } from "../domain/types/queue.js";
|
|
8
|
+
import type { MapLike } from "../shared/lru.js";
|
|
9
|
+
/** Context for job logs operations */
|
|
10
|
+
export interface JobLogsContext {
|
|
11
|
+
jobIndex: Map<JobId, JobLocation>;
|
|
12
|
+
jobLogs: MapLike<JobId, JobLogEntry[]>;
|
|
13
|
+
jobLogQueues: Map<JobId, string>;
|
|
14
|
+
maxLogsPerJob: number;
|
|
15
|
+
}
|
|
16
|
+
/** Add log entry to a job */
|
|
17
|
+
export declare function addJobLog(jobId: JobId, message: string, ctx: JobLogsContext, level?: 'info' | 'warn' | 'error'): boolean;
|
|
18
|
+
/** Get logs for a job */
|
|
19
|
+
export declare function getJobLogs(jobId: JobId, ctx: JobLogsContext): JobLogEntry[];
|
|
20
|
+
/** Clear logs for a job, optionally keeping the most recent N entries */
|
|
21
|
+
export declare function clearJobLogs(jobId: JobId, ctx: JobLogsContext, keepLogs?: number): void;
|