bunqueue-client 0.1.8 → 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 +162 -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} +7 -6
- 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 +12 -8
- 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 -105
- 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,44 @@
|
|
|
1
|
+
import type { StepDefinition, WorkflowNode } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extract step definitions from an inline builder. Inline nodes run inside one
|
|
4
|
+
* `wf:step` job, so only plain steps have executable semantics there.
|
|
5
|
+
*/
|
|
6
|
+
export declare function onlySteps(sub: {
|
|
7
|
+
nodes: readonly WorkflowNode[];
|
|
8
|
+
}, where: string, label?: string): StepDefinition[];
|
|
9
|
+
/** Why an event name cannot be used as a gate, or `null` when it can. */
|
|
10
|
+
export declare function unusableEventName(event: unknown): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* A delivered signal is retained by event name rather than consumed, so two gates
|
|
13
|
+
* sharing a name would both be opened by one delivery.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertNoDuplicateWaitFor(wf: {
|
|
16
|
+
name: string;
|
|
17
|
+
nodes: readonly {
|
|
18
|
+
type: string;
|
|
19
|
+
event?: string;
|
|
20
|
+
}[];
|
|
21
|
+
}): void;
|
|
22
|
+
type RegistrableWorkflow = {
|
|
23
|
+
name: string;
|
|
24
|
+
nodes: readonly WorkflowNode[];
|
|
25
|
+
getStepNames(): string[];
|
|
26
|
+
getIndexedStepNames(): string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Reject both engine namespace collisions and names colliding with the
|
|
30
|
+
* `name:index` records generated by loops.
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertNoIndexCollision(wf: RegistrableWorkflow): void;
|
|
33
|
+
/**
|
|
34
|
+
* `retry` is the total number of attempts. Zero/non-integral values would make the
|
|
35
|
+
* runner skip the handler and fabricate a failure record.
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertUsableRetry(step: string, retry: number | undefined): void;
|
|
38
|
+
/** Timeout values are finite milliseconds; zero deliberately means no forward bound. */
|
|
39
|
+
export declare function assertUsableTimeout(where: string, timeout: number | undefined): void;
|
|
40
|
+
/** Polling delays and child deadlines cannot be disabled or spin at zero. */
|
|
41
|
+
export declare function assertPositiveDuration(where: string, duration: number | undefined): void;
|
|
42
|
+
/** Loop limits must bound the number of body executions exactly. */
|
|
43
|
+
export declare function assertUsableIterations(where: string, maxIterations: number | undefined): void;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bunqueue Configuration
|
|
3
|
+
* Global config file support with defineConfig helper
|
|
4
|
+
*/
|
|
5
|
+
export { defineConfig } from "./types.js";
|
|
6
|
+
export type { BunqueueConfig } from "./types.js";
|
|
7
|
+
export { loadConfigFile } from "./loader.js";
|
|
8
|
+
export { resolveServerConfig, resolveCloudConfig, resolveBackupConfig, resolveTlsServerOptions, } from "./resolve.js";
|
|
9
|
+
export type { ResolvedConfig } from "./resolve.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bunqueue Config File Loader
|
|
3
|
+
* Auto-discovers and loads bunqueue.config.{ts,js,mjs}
|
|
4
|
+
*/
|
|
5
|
+
import type { BunqueueConfig } from "./types.js";
|
|
6
|
+
/** Load config file from explicit path or auto-discover in CWD */
|
|
7
|
+
export declare function loadConfigFile(explicitPath?: string): Promise<BunqueueConfig | null>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bunqueue Config Resolver
|
|
3
|
+
* Merges config file + env vars + defaults (config file wins)
|
|
4
|
+
*/
|
|
5
|
+
import type { BunqueueConfig } from "./types.js";
|
|
6
|
+
import type { CloudConfig } from "../infrastructure/cloud/types.js";
|
|
7
|
+
import type { S3BackupConfig } from "../infrastructure/backup/s3BackupConfig.js";
|
|
8
|
+
/** Fully resolved server configuration */
|
|
9
|
+
export interface ResolvedConfig {
|
|
10
|
+
tcpPort: number;
|
|
11
|
+
httpPort: number;
|
|
12
|
+
hostname: string;
|
|
13
|
+
tcpSocketPath: string | undefined;
|
|
14
|
+
httpSocketPath: string | undefined;
|
|
15
|
+
tlsCertFile: string | undefined;
|
|
16
|
+
tlsKeyFile: string | undefined;
|
|
17
|
+
authTokens: string[];
|
|
18
|
+
dataPath: string | undefined;
|
|
19
|
+
storageDriver: 'memory' | 'sqlite' | 'postgres';
|
|
20
|
+
postgresUrl: string | undefined;
|
|
21
|
+
postgresNamespace: string;
|
|
22
|
+
postgresBrokerId: string | undefined;
|
|
23
|
+
postgresPoolSize: number;
|
|
24
|
+
postgresLeaseDurationMs: number;
|
|
25
|
+
postgresPollIntervalMs: number;
|
|
26
|
+
postgresStatementTimeoutMs: number;
|
|
27
|
+
postgresLockTimeoutMs: number;
|
|
28
|
+
postgresIdleTransactionTimeoutMs: number;
|
|
29
|
+
postgresMaxConcurrentOperations: number;
|
|
30
|
+
postgresMaxQueuedOperations: number;
|
|
31
|
+
postgresMaxSnapshotJobs: number;
|
|
32
|
+
postgresMaxSnapshotPayloadBytes: number;
|
|
33
|
+
maxCompletedJobs: number;
|
|
34
|
+
completedRetentionMs: number | null;
|
|
35
|
+
corsOrigins: string[];
|
|
36
|
+
requireAuthForMetrics: boolean;
|
|
37
|
+
maxPrometheusQueues: number;
|
|
38
|
+
s3BackupEnabled: boolean;
|
|
39
|
+
shutdownTimeoutMs: number;
|
|
40
|
+
statsIntervalMs: number;
|
|
41
|
+
}
|
|
42
|
+
/** Resolve server config: config file > env vars > defaults */
|
|
43
|
+
export declare function resolveServerConfig(fileConfig: BunqueueConfig | null): ResolvedConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve server TLS options from resolved config. Returns null when TLS is
|
|
46
|
+
* not configured; throws when only one of cert/key is set (fail fast at
|
|
47
|
+
* startup rather than serving plaintext when the operator expected TLS).
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveTlsServerOptions(config: {
|
|
50
|
+
tlsCertFile?: string;
|
|
51
|
+
tlsKeyFile?: string;
|
|
52
|
+
}): {
|
|
53
|
+
certFile: string;
|
|
54
|
+
keyFile: string;
|
|
55
|
+
} | null;
|
|
56
|
+
/** Resolve cloud config: config file > env vars. Returns null if disabled. */
|
|
57
|
+
export declare function resolveCloudConfig(fileConfig: BunqueueConfig | null, dataPath?: string): CloudConfig | null;
|
|
58
|
+
/** Resolve S3 backup config: config file > env vars */
|
|
59
|
+
export declare function resolveBackupConfig(fileConfig: BunqueueConfig | null, databasePath: string): S3BackupConfig;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bunqueue Configuration Types
|
|
3
|
+
* Global configuration file interface and defineConfig helper
|
|
4
|
+
*/
|
|
5
|
+
/** Global bunqueue configuration (all sections optional) */
|
|
6
|
+
export interface BunqueueConfig {
|
|
7
|
+
server?: {
|
|
8
|
+
tcpPort?: number;
|
|
9
|
+
httpPort?: number;
|
|
10
|
+
host?: string;
|
|
11
|
+
tcpSocketPath?: string;
|
|
12
|
+
httpSocketPath?: string;
|
|
13
|
+
/** Path to PEM certificate file — enables native TLS on TCP + HTTP (with tlsKeyFile) */
|
|
14
|
+
tlsCertFile?: string;
|
|
15
|
+
/** Path to PEM private key file — enables native TLS on TCP + HTTP (with tlsCertFile) */
|
|
16
|
+
tlsKeyFile?: string;
|
|
17
|
+
};
|
|
18
|
+
auth?: {
|
|
19
|
+
tokens?: string[];
|
|
20
|
+
requireAuthForMetrics?: boolean;
|
|
21
|
+
};
|
|
22
|
+
storage?: {
|
|
23
|
+
/** Persistence backend. Inferred from url/dataPath when omitted. */
|
|
24
|
+
driver?: 'memory' | 'sqlite' | 'postgres';
|
|
25
|
+
dataPath?: string;
|
|
26
|
+
/** PostgreSQL connection URL. Required when driver is postgres. */
|
|
27
|
+
url?: string;
|
|
28
|
+
/** Isolates independent bunqueue installations sharing one PostgreSQL database. */
|
|
29
|
+
namespace?: string;
|
|
30
|
+
/** Stable identifier for this broker process; generated automatically when omitted. */
|
|
31
|
+
brokerId?: string;
|
|
32
|
+
poolSize?: number;
|
|
33
|
+
leaseDurationMs?: number;
|
|
34
|
+
pollIntervalMs?: number;
|
|
35
|
+
statementTimeoutMs?: number;
|
|
36
|
+
lockTimeoutMs?: number;
|
|
37
|
+
idleTransactionTimeoutMs?: number;
|
|
38
|
+
maxConcurrentOperations?: number;
|
|
39
|
+
maxQueuedOperations?: number;
|
|
40
|
+
maxSnapshotJobs?: number;
|
|
41
|
+
maxSnapshotPayloadBytes?: number;
|
|
42
|
+
/** Hot in-memory completed-job window; this is not durable retention. */
|
|
43
|
+
maxCompletedJobs?: number;
|
|
44
|
+
/** Automatic age-based completed-job retention in milliseconds; null disables it. */
|
|
45
|
+
completedRetentionMs?: number | null;
|
|
46
|
+
};
|
|
47
|
+
telemetry?: {
|
|
48
|
+
/** Maximum queue label values exposed to Prometheus; zero disables per-queue series. */
|
|
49
|
+
maxPrometheusQueues?: number;
|
|
50
|
+
};
|
|
51
|
+
cors?: {
|
|
52
|
+
origins?: string[];
|
|
53
|
+
};
|
|
54
|
+
cloud?: {
|
|
55
|
+
url?: string;
|
|
56
|
+
apiKey?: string;
|
|
57
|
+
instanceId?: string;
|
|
58
|
+
};
|
|
59
|
+
backup?: {
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
bucket?: string;
|
|
62
|
+
accessKeyId?: string;
|
|
63
|
+
secretAccessKey?: string;
|
|
64
|
+
sessionToken?: string;
|
|
65
|
+
region?: string;
|
|
66
|
+
endpoint?: string;
|
|
67
|
+
virtualHostedStyle?: boolean;
|
|
68
|
+
interval?: number;
|
|
69
|
+
retention?: number;
|
|
70
|
+
prefix?: string;
|
|
71
|
+
};
|
|
72
|
+
timeouts?: {
|
|
73
|
+
shutdown?: number;
|
|
74
|
+
stats?: number;
|
|
75
|
+
worker?: number;
|
|
76
|
+
lock?: number;
|
|
77
|
+
};
|
|
78
|
+
webhooks?: {
|
|
79
|
+
maxRetries?: number;
|
|
80
|
+
retryDelay?: number;
|
|
81
|
+
};
|
|
82
|
+
logging?: {
|
|
83
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
84
|
+
format?: 'text' | 'json';
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Type-safe config helper for intellisense */
|
|
88
|
+
export declare function defineConfig(config: BunqueueConfig): BunqueueConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DEFAULT_MAX_BACKOFF = 3600000;
|
|
2
|
+
export declare const MAX_TIMELINE_ENTRIES = 20;
|
|
3
|
+
export declare const DEFAULT_LOCK_TTL = 30000;
|
|
4
|
+
export declare const JOB_DEFAULTS: {
|
|
5
|
+
readonly priority: 0;
|
|
6
|
+
readonly maxAttempts: 3;
|
|
7
|
+
readonly backoff: 1000;
|
|
8
|
+
readonly lifo: false;
|
|
9
|
+
readonly removeOnComplete: false;
|
|
10
|
+
readonly removeOnFail: false;
|
|
11
|
+
readonly stackTraceLimit: 10;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Job } from "../types/jobs/model.js";
|
|
2
|
+
/** Read the broker-internal admission order used by grouped FIFO lanes. */
|
|
3
|
+
export declare function getGroupFifoOrder(job: Job): bigint | null;
|
|
4
|
+
/** Stamp a stable order without exposing it through the public job protocol. */
|
|
5
|
+
export declare function setGroupFifoOrder(job: Job, order: bigint): void;
|
|
6
|
+
/** Preserve the hidden order when an immutable job replacement is created. */
|
|
7
|
+
export declare function copyGroupFifoOrder(source: Job, target: Job): void;
|
|
8
|
+
/** Restore a validated decimal order from SQLite extended options. */
|
|
9
|
+
export declare function restoreGroupFifoOrder(job: Job, stored: string | null): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JobId, LockToken } from "../types/jobs/model.js";
|
|
2
|
+
export declare function isWellFormedJobId(id: string): boolean;
|
|
3
|
+
export declare function assertWellFormedJobId(id: string, name?: string): void;
|
|
4
|
+
export declare function jobId(id: string): JobId;
|
|
5
|
+
export declare function generateJobId(): JobId;
|
|
6
|
+
export declare function lockToken(token: string): LockToken;
|
|
7
|
+
export declare function generateLockToken(): LockToken;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JobId, JobLock } from "../types/jobs/model.js";
|
|
2
|
+
export declare function createJobLock(jobId: JobId, owner: string, ttl?: number, now?: number): JobLock;
|
|
3
|
+
export declare function isLockExpired(lock: JobLock, now?: number): boolean;
|
|
4
|
+
export declare function renewLock(lock: JobLock, newTtl?: number, now?: number): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface JobPayloadSource {
|
|
2
|
+
readonly name?: unknown;
|
|
3
|
+
readonly data: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface NormalizedJobPayload {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly data: unknown;
|
|
8
|
+
readonly legacy: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Return the stable public validation error for an invalid job name. */
|
|
11
|
+
export declare function validateJobName(name: unknown): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a modern payload. A missing explicit name defaults without inspecting
|
|
14
|
+
* `data`, so direct QueueManager callers can use `data.name` as an ordinary key.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeJobPayload(source: JobPayloadSource, fallback?: string): NormalizedJobPayload;
|
|
17
|
+
/** Decode a pre-2.8.56 wire or persistence envelope at a known legacy boundary. */
|
|
18
|
+
export declare function normalizeLegacyJobPayload(source: JobPayloadSource, fallback?: string): NormalizedJobPayload;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Job } from "../types/jobs/model.js";
|
|
2
|
+
export declare function normalizeStacktrace(lines: readonly unknown[] | undefined, limit: number): string[] | null;
|
|
3
|
+
export declare function isDelayed(job: Job, now?: number): boolean;
|
|
4
|
+
export declare function isReady(job: Job, now?: number): boolean;
|
|
5
|
+
export declare function isExpired(job: Job, now?: number): boolean;
|
|
6
|
+
export declare function isTimedOut(job: Job, now?: number): boolean;
|
|
7
|
+
export declare function calculateBackoff(job: Job): number;
|
|
8
|
+
export declare function canRetry(job: Job): boolean;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DependencyTracker - Tracks job dependencies and parent-child relationships
|
|
3
|
+
*/
|
|
4
|
+
import type { Job, JobId } from "../types/job.js";
|
|
5
|
+
/**
|
|
6
|
+
* Manages job dependency tracking for a shard
|
|
7
|
+
* Provides O(1) lookup when dependencies complete
|
|
8
|
+
*/
|
|
9
|
+
export declare class DependencyTracker {
|
|
10
|
+
/** Jobs waiting for dependencies */
|
|
11
|
+
readonly waitingDeps: Map<JobId, Job>;
|
|
12
|
+
/**
|
|
13
|
+
* Reverse index: depId -> Set of jobIds waiting for that dependency
|
|
14
|
+
* Enables O(1) lookup when a dependency completes instead of O(n) scan
|
|
15
|
+
*/
|
|
16
|
+
readonly dependencyIndex: Map<JobId, Set<JobId>>;
|
|
17
|
+
/** Parent jobs waiting for children to complete */
|
|
18
|
+
readonly waitingChildren: Map<JobId, Job>;
|
|
19
|
+
/**
|
|
20
|
+
* Register a job's dependencies in the reverse index
|
|
21
|
+
* Call when adding a job to waitingDeps
|
|
22
|
+
*/
|
|
23
|
+
registerDependencies(jobId: JobId, dependsOn: JobId[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Unregister a job's dependencies from the reverse index
|
|
26
|
+
* Call when removing a job from waitingDeps
|
|
27
|
+
*/
|
|
28
|
+
unregisterDependencies(jobId: JobId, dependsOn: JobId[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get jobs waiting for a specific dependency - O(1)
|
|
31
|
+
*/
|
|
32
|
+
getJobsWaitingFor(depId: JobId): Set<JobId> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Add a job that is waiting for dependencies
|
|
35
|
+
*/
|
|
36
|
+
addWaitingJob(job: Job): void;
|
|
37
|
+
/**
|
|
38
|
+
* Remove a job from waiting deps
|
|
39
|
+
*/
|
|
40
|
+
removeWaitingJob(jobId: JobId): Job | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get a job waiting for dependencies
|
|
43
|
+
*/
|
|
44
|
+
getWaitingJob(jobId: JobId): Job | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a job is waiting for dependencies
|
|
47
|
+
*/
|
|
48
|
+
isWaiting(jobId: JobId): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Add a parent job waiting for children
|
|
51
|
+
*/
|
|
52
|
+
addWaitingParent(job: Job): void;
|
|
53
|
+
/**
|
|
54
|
+
* Remove a parent job from waiting
|
|
55
|
+
*/
|
|
56
|
+
removeWaitingParent(jobId: JobId): Job | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Remove every dependency-gated job owned by a queue.
|
|
59
|
+
* Returns the removed ids so the caller can purge global indexes and storage.
|
|
60
|
+
*/
|
|
61
|
+
removeQueue(queue: string): JobId[];
|
|
62
|
+
/**
|
|
63
|
+
* Get a parent job waiting for children
|
|
64
|
+
*/
|
|
65
|
+
getWaitingParent(jobId: JobId): Job | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a parent is waiting for children
|
|
68
|
+
*/
|
|
69
|
+
isParentWaiting(jobId: JobId): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get counts for debugging
|
|
72
|
+
*/
|
|
73
|
+
getCounts(): {
|
|
74
|
+
waitingDeps: number;
|
|
75
|
+
dependencyIndex: number;
|
|
76
|
+
waitingChildren: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DlqShard - Dead Letter Queue operations for a shard
|
|
3
|
+
*/
|
|
4
|
+
import type { Job, JobId } from "../types/job.js";
|
|
5
|
+
import type { DlqEntry, DlqConfig, DlqFilter } from "../types/dlq.js";
|
|
6
|
+
import { FailureReason } from "../types/dlq.js";
|
|
7
|
+
import type { StallConfig } from "../types/stall.js";
|
|
8
|
+
/** Stats callback for counter updates */
|
|
9
|
+
export interface DlqStatsCallback {
|
|
10
|
+
incrementDlq(): void;
|
|
11
|
+
decrementDlq(count?: number): void;
|
|
12
|
+
onEvict?(entry: DlqEntry): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Manages Dead Letter Queue operations for a shard
|
|
16
|
+
*/
|
|
17
|
+
export declare class DlqShard {
|
|
18
|
+
/** Dead letter queue by queue name */
|
|
19
|
+
private readonly dlq;
|
|
20
|
+
/** DLQ configuration per queue */
|
|
21
|
+
private readonly dlqConfig;
|
|
22
|
+
/** Stall configuration per queue */
|
|
23
|
+
private readonly stallConfig;
|
|
24
|
+
/** Stats callback for counter updates */
|
|
25
|
+
private readonly stats;
|
|
26
|
+
constructor(stats: DlqStatsCallback);
|
|
27
|
+
/** Get DLQ config for queue */
|
|
28
|
+
getConfig(queue: string): DlqConfig;
|
|
29
|
+
/** Set DLQ config for queue */
|
|
30
|
+
setConfig(queue: string, config: Partial<DlqConfig>): void;
|
|
31
|
+
/** Get stall config for queue */
|
|
32
|
+
getStallConfig(queue: string): StallConfig;
|
|
33
|
+
/** Set stall config for queue */
|
|
34
|
+
setStallConfig(queue: string, config: Partial<StallConfig>): void;
|
|
35
|
+
/** Add job to DLQ with full metadata */
|
|
36
|
+
add(job: Job, reason?: FailureReason, error?: string | null): DlqEntry;
|
|
37
|
+
/** Restore an existing DlqEntry (for recovery from persistence) */
|
|
38
|
+
restoreEntry(queue: string, entry: DlqEntry): void;
|
|
39
|
+
/** Get DLQ entries (raw) */
|
|
40
|
+
getEntries(queue: string): DlqEntry[];
|
|
41
|
+
/** Get DLQ jobs (for backward compatibility) */
|
|
42
|
+
getJobs(queue: string, count?: number): Job[];
|
|
43
|
+
/** Get DLQ entries with filter */
|
|
44
|
+
getFiltered(queue: string, filter: DlqFilter): DlqEntry[];
|
|
45
|
+
/** Remove entry from DLQ by job ID */
|
|
46
|
+
remove(queue: string, jobId: JobId): DlqEntry | null;
|
|
47
|
+
/** Remove every entry with the same job ID from one queue. */
|
|
48
|
+
removeAll(queue: string, jobId: JobId): DlqEntry[];
|
|
49
|
+
/** Get entries ready for auto-retry */
|
|
50
|
+
getAutoRetryEntries(queue: string, now?: number): DlqEntry[];
|
|
51
|
+
/** Get expired entries for cleanup */
|
|
52
|
+
getExpiredEntries(queue: string, now?: number): DlqEntry[];
|
|
53
|
+
/** Remove expired entries */
|
|
54
|
+
purgeExpired(queue: string, now?: number): number;
|
|
55
|
+
/** Clear DLQ for queue */
|
|
56
|
+
clear(queue: string): number;
|
|
57
|
+
/** Get DLQ count for queue */
|
|
58
|
+
getCount(queue: string): number;
|
|
59
|
+
/** Get all queue names with DLQ entries */
|
|
60
|
+
getQueueNames(): string[];
|
|
61
|
+
/** Get queue names with persisted DLQ or stall policy. */
|
|
62
|
+
getConfiguredQueueNames(): string[];
|
|
63
|
+
/** Delete queue data */
|
|
64
|
+
deleteQueue(queue: string): number;
|
|
65
|
+
private evictUntil;
|
|
66
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type GroupPullOptions, type GroupRateLimitOverride } from "../types/group.js";
|
|
2
|
+
export interface GroupLimitStatus {
|
|
3
|
+
eligible: boolean;
|
|
4
|
+
retryAt: number | null;
|
|
5
|
+
}
|
|
6
|
+
/** Stored group overrides and broker-authoritative runtime rate windows. */
|
|
7
|
+
export declare class GroupLimiterManager {
|
|
8
|
+
private readonly rateOverrides;
|
|
9
|
+
private readonly concurrencyOverrides;
|
|
10
|
+
private readonly windows;
|
|
11
|
+
private readonly manualRateLimits;
|
|
12
|
+
private readonly paused;
|
|
13
|
+
status(queue: string, groupId: string, defaults: GroupPullOptions | undefined, active: number, now?: number): GroupLimitStatus;
|
|
14
|
+
acquire(queue: string, groupId: string, defaults: GroupPullOptions | undefined, active: number, now?: number): boolean;
|
|
15
|
+
setRateLimit(queue: string, groupId: string, max: number, duration: number): void;
|
|
16
|
+
getRateLimit(queue: string, groupId: string): GroupRateLimitOverride | null;
|
|
17
|
+
removeRateLimit(queue: string, groupId: string): number;
|
|
18
|
+
getRateLimitTtl(queue: string, groupId: string, maxJobs?: number, now?: number): number;
|
|
19
|
+
setConcurrency(queue: string, groupId: string, concurrency: number): void;
|
|
20
|
+
getConcurrency(queue: string, groupId: string): number | null;
|
|
21
|
+
removeConcurrency(queue: string, groupId: string): number;
|
|
22
|
+
pause(queue: string, groupId: string): boolean;
|
|
23
|
+
resume(queue: string, groupId: string): boolean;
|
|
24
|
+
isPaused(queue: string, groupId: string): boolean;
|
|
25
|
+
rateLimit(queue: string, groupId: string, duration: number, now?: number): void;
|
|
26
|
+
getQueueNames(): string[];
|
|
27
|
+
clearQueue(queue: string): void;
|
|
28
|
+
pruneExpiredWindows(now?: number): void;
|
|
29
|
+
private currentWindow;
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Job } from "../types/job.js";
|
|
2
|
+
export interface GroupEligibility {
|
|
3
|
+
eligible: boolean;
|
|
4
|
+
retryAt: number | null;
|
|
5
|
+
}
|
|
6
|
+
export interface GroupCandidate {
|
|
7
|
+
job: Job | null;
|
|
8
|
+
nextRunAt: number | null;
|
|
9
|
+
}
|
|
10
|
+
/** Lazy secondary ready/group indexes; the primary queue remains authoritative. */
|
|
11
|
+
export declare class GroupScheduler {
|
|
12
|
+
private readonly queues;
|
|
13
|
+
private nextFifoOrder;
|
|
14
|
+
assignFifoOrder(job: Job): void;
|
|
15
|
+
observeFifoOrder(job: Job): void;
|
|
16
|
+
insert(queue: string, job: Job, primaryJobs: () => readonly Job[], now?: number): boolean;
|
|
17
|
+
remove(queue: string, job: Job): boolean;
|
|
18
|
+
isActive(queue: string): boolean;
|
|
19
|
+
peek(queue: string, now: number, eligibility: (groupId: string) => GroupEligibility, affinity?: string | null): GroupCandidate;
|
|
20
|
+
advance(queue: string, groupId: string): void;
|
|
21
|
+
getGroupJobsCount(queue: string, groupId: string): number;
|
|
22
|
+
getGroupsJobsCount(queue: string): number;
|
|
23
|
+
clearQueue(queue: string): void;
|
|
24
|
+
private createState;
|
|
25
|
+
private insertTracked;
|
|
26
|
+
private promoteDue;
|
|
27
|
+
private insertReady;
|
|
28
|
+
private demoteReady;
|
|
29
|
+
private attachLane;
|
|
30
|
+
private detachLane;
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Job } from "../types/job.js";
|
|
2
|
+
import type { HeapEntry } from "../types/priorityQueue.js";
|
|
3
|
+
export declare function orderedGroupClone(job: Job, runAt?: number): Job;
|
|
4
|
+
export declare function nextGroupCheckAt(job: Job): number;
|
|
5
|
+
export declare function compareGroupFifoEntries(left: HeapEntry, right: HeapEntry): number;
|
|
6
|
+
export declare function compareGroupWakeEntries(left: HeapEntry, right: HeapEntry): number;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LimiterManager - Rate limiting and concurrency control
|
|
3
|
+
*/
|
|
4
|
+
import { type QueueState } from "../types/queue.js";
|
|
5
|
+
/**
|
|
6
|
+
* Manages rate limiting and concurrency for queues
|
|
7
|
+
*/
|
|
8
|
+
export declare class LimiterManager {
|
|
9
|
+
/** Queue state (pause, rate limit, concurrency) */
|
|
10
|
+
private readonly queueState;
|
|
11
|
+
/** Rate limiters per queue */
|
|
12
|
+
private readonly rateLimiters;
|
|
13
|
+
/** Concurrency limiters per queue */
|
|
14
|
+
private readonly concurrencyLimiters;
|
|
15
|
+
/** Get queue state */
|
|
16
|
+
getState(name: string): QueueState;
|
|
17
|
+
/** Check if queue is paused */
|
|
18
|
+
isPaused(name: string): boolean;
|
|
19
|
+
/** Pause queue */
|
|
20
|
+
pause(name: string): void;
|
|
21
|
+
/** Resume queue */
|
|
22
|
+
resume(name: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Set rate limit for queue.
|
|
25
|
+
* @param durationMs window the limit applies to (default 1000ms): `limit`
|
|
26
|
+
* tokens refill over `durationMs`. Non-finite or non-positive → default.
|
|
27
|
+
* @param ttlMs auto-expiry: the limit clears itself after this many ms
|
|
28
|
+
* (lazy, checked on acquire/read). Non-finite or non-positive → permanent.
|
|
29
|
+
*/
|
|
30
|
+
setRateLimit(queue: string, limit: number, durationMs?: number, ttlMs?: number): void;
|
|
31
|
+
/** Clear rate limit */
|
|
32
|
+
clearRateLimit(queue: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Drop the rate limit if its TTL has elapsed. Lazy expiry: called from the
|
|
35
|
+
* acquire path and from limit reads, so no timer is needed and an expired
|
|
36
|
+
* limit can never throttle a pull.
|
|
37
|
+
*/
|
|
38
|
+
expireRateLimitIfNeeded(queue: string, now?: number): void;
|
|
39
|
+
/** Try to acquire rate limit token */
|
|
40
|
+
tryAcquireRateLimit(queue: string): boolean;
|
|
41
|
+
/** Read the active rate-limit configuration after applying lazy expiry. */
|
|
42
|
+
getRateLimit(queue: string): {
|
|
43
|
+
max: number;
|
|
44
|
+
duration: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/** Read the remaining temporary-limit TTL or token-bucket cooldown. */
|
|
47
|
+
getRateLimitTtl(queue: string, maxJobs?: number): number;
|
|
48
|
+
/** Set concurrency limit for queue */
|
|
49
|
+
setConcurrency(queue: string, limit: number): void;
|
|
50
|
+
/** Clear concurrency limit */
|
|
51
|
+
clearConcurrency(queue: string): void;
|
|
52
|
+
/** Try to acquire concurrency slot */
|
|
53
|
+
tryAcquireConcurrency(queue: string): boolean;
|
|
54
|
+
/** Release concurrency slot */
|
|
55
|
+
releaseConcurrency(queue: string): void;
|
|
56
|
+
/** Read the configured global concurrency limit. */
|
|
57
|
+
getConcurrency(queue: string): number | null;
|
|
58
|
+
/** Whether all configured global concurrency slots are currently occupied. */
|
|
59
|
+
isConcurrencyMaxed(queue: string): boolean;
|
|
60
|
+
/** Get all queue names with state */
|
|
61
|
+
getQueueNames(): string[];
|
|
62
|
+
/** Get queues whose state contains an explicit policy rather than read-created defaults. */
|
|
63
|
+
getConfiguredQueueNames(now?: number): string[];
|
|
64
|
+
/** Delete queue data */
|
|
65
|
+
deleteQueue(queue: string): void;
|
|
66
|
+
/** Get the underlying state map (for backward compatibility) */
|
|
67
|
+
getStateMap(): Map<string, QueueState>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Job, JobId } from "../types/job.js";
|
|
2
|
+
import type { HeapEntry } from "../types/priorityQueue.js";
|
|
3
|
+
export interface PriorityQueueHooks {
|
|
4
|
+
onInsert(job: Job): boolean;
|
|
5
|
+
onRemove(job: Job): boolean;
|
|
6
|
+
}
|
|
7
|
+
export type PriorityQueueComparator = (left: HeapEntry, right: HeapEntry) => number;
|
|
8
|
+
export type PriorityQueueOrder = (job: Job) => bigint | null;
|
|
9
|
+
/** Indexed map-backed 4-ary heap with O(log4 n) mutations and O(1) lookup. */
|
|
10
|
+
export declare class IndexedPriorityQueue {
|
|
11
|
+
private readonly hooks?;
|
|
12
|
+
private readonly compare;
|
|
13
|
+
private readonly order?;
|
|
14
|
+
private static readonly D;
|
|
15
|
+
private heap;
|
|
16
|
+
private readonly index;
|
|
17
|
+
private generation;
|
|
18
|
+
private hooksActive;
|
|
19
|
+
constructor(hooks?: PriorityQueueHooks | undefined, compare?: PriorityQueueComparator, order?: PriorityQueueOrder | undefined);
|
|
20
|
+
get size(): number;
|
|
21
|
+
get isEmpty(): boolean;
|
|
22
|
+
push(job: Job): void;
|
|
23
|
+
pop(): Job | null;
|
|
24
|
+
peek(): Job | null;
|
|
25
|
+
find(jobId: JobId): Job | null;
|
|
26
|
+
has(jobId: JobId): boolean;
|
|
27
|
+
remove(jobId: JobId): Job | null;
|
|
28
|
+
/** Update job priority - O(log n). Optionally update the LIFO tie-break flag. */
|
|
29
|
+
updatePriority(jobId: JobId, newPriority: number, newLifo?: boolean): boolean;
|
|
30
|
+
/** Update job runAt (for delay changes) - O(log n) */
|
|
31
|
+
updateRunAt(jobId: JobId, newRunAt: number): boolean;
|
|
32
|
+
values(): Job[];
|
|
33
|
+
clear(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get the ratio of stale entries in the heap
|
|
36
|
+
* Used to decide when to compact
|
|
37
|
+
*/
|
|
38
|
+
getStaleRatio(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Compact the heap by removing stale entries
|
|
41
|
+
* Call when stale ratio exceeds threshold (e.g., 20%)
|
|
42
|
+
* O(n) operation but reclaims memory and improves performance
|
|
43
|
+
*/
|
|
44
|
+
compact(): void;
|
|
45
|
+
private heapify;
|
|
46
|
+
/** Check if compaction is needed (stale ratio > threshold) */
|
|
47
|
+
needsCompaction(threshold?: number): boolean;
|
|
48
|
+
private removeTop;
|
|
49
|
+
/** 4-ary bubbleUp: parent at floor((idx-1)/D) */
|
|
50
|
+
private bubbleUp;
|
|
51
|
+
/** 4-ary bubbleDown: children at D*idx+1 through D*idx+D */
|
|
52
|
+
private bubbleDown;
|
|
53
|
+
private swap;
|
|
54
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Job, JobId } from "../../types/job.js";
|
|
2
|
+
import { ShardLimits } from "./limits.js";
|
|
3
|
+
/** Dependency and waiting-children maps. */
|
|
4
|
+
export declare class ShardDependencies extends ShardLimits {
|
|
5
|
+
get waitingDeps(): Map<JobId, Job>;
|
|
6
|
+
get dependencyIndex(): Map<JobId, Set<JobId>>;
|
|
7
|
+
get waitingChildren(): Map<JobId, Job>;
|
|
8
|
+
registerDependencies(jobId: JobId, dependsOn: JobId[]): void;
|
|
9
|
+
unregisterDependencies(jobId: JobId, dependsOn: JobId[]): void;
|
|
10
|
+
getJobsWaitingFor(depId: JobId): Set<JobId> | undefined;
|
|
11
|
+
}
|