bunqueue-client 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +165 -0
- package/LEGACY.md +460 -0
- package/README.md +204 -349
- package/dist/ack-batcher.js +7 -67
- package/dist/canonical-manifest.json +934 -0
- package/dist/chunk-b967v3w3.js +79 -0
- package/dist/chunk-fekm0ma6.js +110 -0
- package/dist/chunk-jxkszwqp.js +573 -0
- package/dist/embedded.js +16510 -0
- package/dist/frame.js +14 -57
- package/dist/index.d.ts +1 -27
- package/dist/index.js +10953 -16
- package/dist/legacy.d.ts +1 -0
- package/dist/legacy.js +2081 -0
- package/dist/{ack-batcher.d.ts → types/sdk/typescript/src/ack-batcher.d.ts} +3 -3
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/aging.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/batch.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue-api.d.ts +5 -5
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/bunqueue.d.ts +13 -13
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/circuit-breaker.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dedup-debounce.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/dlq-rate-limit.d.ts +2 -2
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/rate-gate.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/retry.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/triggers.d.ts +3 -3
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/ttl.d.ts +1 -1
- package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/types.d.ts +4 -4
- package/dist/types/sdk/typescript/src/canonical-transport/bun-sqlite-types.d.ts +21 -0
- package/dist/{connection-pool.d.ts → types/sdk/typescript/src/connection-pool.d.ts} +1 -1
- package/dist/{connection-types.d.ts → types/sdk/typescript/src/connection-types.d.ts} +1 -1
- package/dist/{connection.d.ts → types/sdk/typescript/src/connection.d.ts} +6 -19
- package/dist/{errors.d.ts → types/sdk/typescript/src/errors.d.ts} +3 -0
- package/dist/types/sdk/typescript/src/flow-commit.d.ts +5 -0
- package/dist/types/sdk/typescript/src/flow-plan-legacy.d.ts +13 -0
- package/dist/types/sdk/typescript/src/flow-plan.d.ts +29 -0
- package/dist/{flow-types.d.ts → types/sdk/typescript/src/flow-types.d.ts} +7 -4
- package/dist/{flow.d.ts → types/sdk/typescript/src/flow.d.ts} +6 -10
- package/dist/{frame.d.ts → types/sdk/typescript/src/frame.d.ts} +1 -1
- package/dist/types/sdk/typescript/src/index.d.ts +10 -0
- package/dist/{job.d.ts → types/sdk/typescript/src/job.d.ts} +4 -3
- package/dist/types/sdk/typescript/src/legacy.d.ts +27 -0
- package/dist/{observability.d.ts → types/sdk/typescript/src/observability.d.ts} +14 -0
- package/dist/{queue-admin.d.ts → types/sdk/typescript/src/queue-admin.d.ts} +3 -4
- package/dist/{queue-control.d.ts → types/sdk/typescript/src/queue-control.d.ts} +5 -5
- package/dist/{queue-query.d.ts → types/sdk/typescript/src/queue-query.d.ts} +3 -3
- package/dist/{queue.d.ts → types/sdk/typescript/src/queue.d.ts} +8 -8
- package/dist/{responses.d.ts → types/sdk/typescript/src/responses.d.ts} +2 -2
- package/dist/types/sdk/typescript/src/serialization.d.ts +10 -0
- package/dist/{socket-factory.d.ts → types/sdk/typescript/src/socket-factory.d.ts} +1 -1
- package/dist/types/sdk/typescript/src/terminal-outcome.d.ts +8 -0
- package/dist/{types.d.ts → types/sdk/typescript/src/types.d.ts} +5 -2
- package/dist/{worker-base.d.ts → types/sdk/typescript/src/worker-base.d.ts} +6 -6
- package/dist/types/sdk/typescript/src/worker-slot-signal.d.ts +6 -0
- package/dist/{worker-types.d.ts → types/sdk/typescript/src/worker-types.d.ts} +3 -3
- package/dist/{worker.d.ts → types/sdk/typescript/src/worker.d.ts} +3 -2
- package/dist/types/src/application/background/dlq.d.ts +2 -0
- package/dist/types/src/application/background/lifecycle.d.ts +4 -0
- package/dist/types/src/application/background/recovery/active.d.ts +5 -0
- package/dist/types/src/application/background/recovery/index.d.ts +2 -0
- package/dist/types/src/application/background/recovery/pending.d.ts +3 -0
- package/dist/types/src/application/background/recovery/restore.d.ts +5 -0
- package/dist/types/src/application/background/recovery/shared.d.ts +6 -0
- package/dist/types/src/application/background/timeouts.d.ts +25 -0
- package/dist/types/src/application/backgroundTasks.d.ts +7 -0
- package/dist/types/src/application/cleanupTasks.d.ts +10 -0
- package/dist/types/src/application/clientOwnership.d.ts +65 -0
- package/dist/types/src/application/clientTracking.d.ts +40 -0
- package/dist/types/src/application/completedCleanup.d.ts +34 -0
- package/dist/types/src/application/completedRetry.d.ts +21 -0
- package/dist/types/src/application/contextFactory.d.ts +49 -0
- package/dist/types/src/application/dependencyCompletions.d.ts +63 -0
- package/dist/types/src/application/dependencyProcessor.d.ts +15 -0
- package/dist/types/src/application/dependencyResultTracker.d.ts +18 -0
- package/dist/types/src/application/dlqManager.d.ts +49 -0
- package/dist/types/src/application/dlqRetry.d.ts +12 -0
- package/dist/types/src/application/emptyQueueCleanup.d.ts +3 -0
- package/dist/types/src/application/eventsManager.d.ts +50 -0
- package/dist/types/src/application/flowFailureRecovery.d.ts +20 -0
- package/dist/types/src/application/flowParentBackpatch.d.ts +27 -0
- package/dist/types/src/application/jobLogsManager.d.ts +21 -0
- package/dist/types/src/application/latencyTracker.d.ts +39 -0
- package/dist/types/src/application/lockManager.d.ts +15 -0
- package/dist/types/src/application/lockOperations.d.ts +38 -0
- package/dist/types/src/application/metricsExporter.d.ts +27 -0
- package/dist/types/src/application/monitoringChecks.d.ts +36 -0
- package/dist/types/src/application/operations/ack/batch.d.ts +8 -0
- package/dist/types/src/application/operations/ack/completion.d.ts +3 -0
- package/dist/types/src/application/operations/ack/failure.d.ts +3 -0
- package/dist/types/src/application/operations/ack.d.ts +5 -0
- package/dist/types/src/application/operations/ackHelpers.d.ts +36 -0
- package/dist/types/src/application/operations/customId.d.ts +51 -0
- package/dist/types/src/application/operations/flowPush.d.ts +9 -0
- package/dist/types/src/application/operations/flowTopologyValidation.d.ts +3 -0
- package/dist/types/src/application/operations/flowValidation.d.ts +3 -0
- package/dist/types/src/application/operations/jobClaim.d.ts +17 -0
- package/dist/types/src/application/operations/jobManagement.d.ts +45 -0
- package/dist/types/src/application/operations/jobMoveOperations.d.ts +9 -0
- package/dist/types/src/application/operations/jobPromotion.d.ts +7 -0
- package/dist/types/src/application/operations/jobStateTransitions.d.ts +15 -0
- package/dist/types/src/application/operations/parentLink.d.ts +36 -0
- package/dist/types/src/application/operations/parentLinkInput.d.ts +8 -0
- package/dist/types/src/application/operations/pull.d.ts +20 -0
- package/dist/types/src/application/operations/pullFinalization.d.ts +6 -0
- package/dist/types/src/application/operations/pullStateTransition.d.ts +51 -0
- package/dist/types/src/application/operations/push.d.ts +13 -0
- package/dist/types/src/application/operations/pushAdmission.d.ts +36 -0
- package/dist/types/src/application/operations/pushBatch.d.ts +4 -0
- package/dist/types/src/application/operations/pushContext.d.ts +48 -0
- package/dist/types/src/application/operations/pushDeduplication.d.ts +42 -0
- package/dist/types/src/application/operations/pushInsert.d.ts +39 -0
- package/dist/types/src/application/operations/pushLocks.d.ts +15 -0
- package/dist/types/src/application/operations/query/collect.d.ts +12 -0
- package/dist/types/src/application/operations/query/jobLookup.d.ts +9 -0
- package/dist/types/src/application/operations/query/pagination.d.ts +8 -0
- package/dist/types/src/application/operations/query/state.d.ts +4 -0
- package/dist/types/src/application/operations/queryOperations.d.ts +5 -0
- package/dist/types/src/application/operations/queueControl.d.ts +50 -0
- package/dist/types/src/application/orphanRecovery.d.ts +25 -0
- package/dist/types/src/application/prometheusOperationalMetrics.d.ts +31 -0
- package/dist/types/src/application/queue-manager/ack.d.ts +23 -0
- package/dist/types/src/application/queue-manager/configuration.d.ts +27 -0
- package/dist/types/src/application/queue-manager/context.d.ts +5 -0
- package/dist/types/src/application/queue-manager/control.d.ts +20 -0
- package/dist/types/src/application/queue-manager/delivery.d.ts +33 -0
- package/dist/types/src/application/queue-manager/dependencies.d.ts +8 -0
- package/dist/types/src/application/queue-manager/dependency-runtime.d.ts +8 -0
- package/dist/types/src/application/queue-manager/flow-failures.d.ts +18 -0
- package/dist/types/src/application/queue-manager/flow-options.d.ts +8 -0
- package/dist/types/src/application/queue-manager/job-management.d.ts +17 -0
- package/dist/types/src/application/queue-manager/lifecycle.d.ts +4 -0
- package/dist/types/src/application/queue-manager/limits.d.ts +58 -0
- package/dist/types/src/application/queue-manager/locks.d.ts +21 -0
- package/dist/types/src/application/queue-manager/observability.d.ts +16 -0
- package/dist/types/src/application/queue-manager/queries.d.ts +24 -0
- package/dist/types/src/application/queue-manager/repeat.d.ts +4 -0
- package/dist/types/src/application/queue-manager/services.d.ts +19 -0
- package/dist/types/src/application/queue-manager/state.d.ts +98 -0
- package/dist/types/src/application/queue-manager/stats.d.ts +28 -0
- package/dist/types/src/application/queueManager.d.ts +5 -0
- package/dist/types/src/application/queueStatsAggregator.d.ts +23 -0
- package/dist/types/src/application/queueTelemetryJournal.d.ts +24 -0
- package/dist/types/src/application/repeatJobs.d.ts +7 -0
- package/dist/types/src/application/stallDetection.d.ts +26 -0
- package/dist/types/src/application/statsManager.d.ts +59 -0
- package/dist/types/src/application/taskErrorTracking.d.ts +22 -0
- package/dist/types/src/application/throughputTracker.d.ts +34 -0
- package/dist/types/src/application/types/ack.d.ts +136 -0
- package/dist/types/src/application/types/background.d.ts +18 -0
- package/dist/types/src/application/types/config.d.ts +41 -0
- package/dist/types/src/application/types/contextFactory.d.ts +89 -0
- package/dist/types/src/application/types/contexts.d.ts +117 -0
- package/dist/types/src/application/types/index.d.ts +7 -0
- package/dist/types/src/application/types/query.d.ts +23 -0
- package/dist/types/src/application/types/queueManager.d.ts +100 -0
- package/dist/types/src/application/webhookManager.d.ts +47 -0
- package/dist/types/src/application/workerManager.d.ts +61 -0
- package/dist/types/src/client/bunqueue/aging.d.ts +16 -0
- package/dist/types/src/client/bunqueue/batch.d.ts +16 -0
- package/dist/types/src/client/bunqueue/cancellation.d.ts +21 -0
- package/dist/types/src/client/bunqueue/circuitBreaker.d.ts +21 -0
- package/dist/types/src/client/bunqueue/dedupDebounce.d.ts +12 -0
- package/dist/types/src/client/bunqueue/dlqRateLimit.d.ts +26 -0
- package/dist/types/src/client/bunqueue/retry.d.ts +8 -0
- package/dist/types/src/client/bunqueue/runtime.d.ts +35 -0
- package/dist/types/src/client/bunqueue/triggers.d.ts +17 -0
- package/dist/types/src/client/bunqueue/ttl.d.ts +17 -0
- package/dist/types/src/client/bunqueue/types.d.ts +147 -0
- package/dist/types/src/client/bunqueue.d.ts +73 -0
- package/dist/types/src/client/dlqConversion.d.ts +5 -0
- package/dist/types/src/client/errors.d.ts +24 -0
- package/dist/types/src/client/events.d.ts +85 -0
- package/dist/types/src/client/flow.d.ts +70 -0
- package/dist/types/src/client/flowAtomic.d.ts +9 -0
- package/dist/types/src/client/flowJobCoreMethods.d.ts +28 -0
- package/dist/types/src/client/flowJobDependencies.d.ts +7 -0
- package/dist/types/src/client/flowJobFactory.d.ts +24 -0
- package/dist/types/src/client/flowJobMoveMethods.d.ts +16 -0
- package/dist/types/src/client/flowJobTypes.d.ts +29 -0
- package/dist/types/src/client/flowLegacyPlan.d.ts +16 -0
- package/dist/types/src/client/flowOptions.d.ts +10 -0
- package/dist/types/src/client/flowPlan.d.ts +16 -0
- package/dist/types/src/client/flowPush.d.ts +27 -0
- package/dist/types/src/client/flowReader.d.ts +10 -0
- package/dist/types/src/client/flowResults.d.ts +11 -0
- package/dist/types/src/client/flowTypes.d.ts +77 -0
- package/dist/types/src/client/forwarder.d.ts +75 -0
- package/dist/types/src/client/groupId.d.ts +1 -0
- package/dist/types/src/client/index.d.ts +46 -0
- package/dist/types/src/client/jobConversion.d.ts +10 -0
- package/dist/types/src/client/jobConversionHelpers.d.ts +28 -0
- package/dist/types/src/client/jobConversionTypes.d.ts +88 -0
- package/dist/types/src/client/jobDeduplication.d.ts +6 -0
- package/dist/types/src/client/jobHelpers.d.ts +31 -0
- package/dist/types/src/client/legacyConnectionOptions.d.ts +8 -0
- package/dist/types/src/client/manager.d.ts +15 -0
- package/dist/types/src/client/pro.d.ts +9 -0
- package/dist/types/src/client/queue/addBatcher.d.ts +59 -0
- package/dist/types/src/client/queue/bullmqCompat.d.ts +57 -0
- package/dist/types/src/client/queue/deduplication.d.ts +14 -0
- package/dist/types/src/client/queue/dlq.d.ts +61 -0
- package/dist/types/src/client/queue/dlqJobMethods.d.ts +9 -0
- package/dist/types/src/client/queue/dlqOps.d.ts +26 -0
- package/dist/types/src/client/queue/dlqStats.d.ts +3 -0
- package/dist/types/src/client/queue/failWire.d.ts +17 -0
- package/dist/types/src/client/queue/helpers.d.ts +19 -0
- package/dist/types/src/client/queue/job-proxy/dependencies.d.ts +9 -0
- package/dist/types/src/client/queue/job-proxy/reflection.d.ts +2 -0
- package/dist/types/src/client/queue/job-proxy/simple.d.ts +3 -0
- package/dist/types/src/client/queue/job-proxy/tcp.d.ts +4 -0
- package/dist/types/src/client/queue/jobMetadata.d.ts +10 -0
- package/dist/types/src/client/queue/jobMove.d.ts +32 -0
- package/dist/types/src/client/queue/jobProxy.d.ts +4 -0
- package/dist/types/src/client/queue/operations/add/bulk.d.ts +7 -0
- package/dist/types/src/client/queue/operations/add/payload.d.ts +25 -0
- package/dist/types/src/client/queue/operations/add/single.d.ts +3 -0
- package/dist/types/src/client/queue/operations/add.d.ts +2 -0
- package/dist/types/src/client/queue/operations/control.d.ts +42 -0
- package/dist/types/src/client/queue/operations/counts.d.ts +48 -0
- package/dist/types/src/client/queue/operations/groups.d.ts +24 -0
- package/dist/types/src/client/queue/operations/management.d.ts +51 -0
- package/dist/types/src/client/queue/operations/query.d.ts +50 -0
- package/dist/types/src/client/queue/operations/queryStates.d.ts +13 -0
- package/dist/types/src/client/queue/operations/queryTcpPages.d.ts +14 -0
- package/dist/types/src/client/queue/queue.d.ts +12 -0
- package/dist/types/src/client/queue/rateLimit.d.ts +46 -0
- package/dist/types/src/client/queue/runtime/compatibility.d.ts +13 -0
- package/dist/types/src/client/queue/runtime/configuration.d.ts +46 -0
- package/dist/types/src/client/queue/runtime/connection.d.ts +6 -0
- package/dist/types/src/client/queue/runtime/control.d.ts +41 -0
- package/dist/types/src/client/queue/runtime/queries.d.ts +66 -0
- package/dist/types/src/client/queue/runtime/scheduling.d.ts +33 -0
- package/dist/types/src/client/queue/runtime/state.d.ts +101 -0
- package/dist/types/src/client/queue/scheduler.d.ts +58 -0
- package/dist/types/src/client/queue/schedulerPagination.d.ts +7 -0
- package/dist/types/src/client/queue/stall.d.ts +20 -0
- package/dist/types/src/client/queue/types/add.d.ts +40 -0
- package/dist/types/src/client/queue/types/contexts.d.ts +33 -0
- package/dist/types/src/client/queue/types/index.d.ts +3 -0
- package/dist/types/src/client/queue/types/job.d.ts +50 -0
- package/dist/types/src/client/queue/types/runtime.d.ts +35 -0
- package/dist/types/src/client/queue/workers.d.ts +36 -0
- package/dist/types/src/client/queue-events/tcpSubscription.d.ts +23 -0
- package/dist/types/src/client/queue.d.ts +5 -0
- package/dist/types/src/client/queueGroup.d.ts +51 -0
- package/dist/types/src/client/resolveToken.d.ts +10 -0
- package/dist/types/src/client/sandboxed/index.d.ts +7 -0
- package/dist/types/src/client/sandboxed/queueOps.d.ts +24 -0
- package/dist/types/src/client/sandboxed/runtime/dispatch.d.ts +13 -0
- package/dist/types/src/client/sandboxed/runtime/lifecycle.d.ts +20 -0
- package/dist/types/src/client/sandboxed/runtime/log.d.ts +1 -0
- package/dist/types/src/client/sandboxed/runtime/pool.d.ts +11 -0
- package/dist/types/src/client/sandboxed/runtime/recovery.d.ts +11 -0
- package/dist/types/src/client/sandboxed/runtime/state.d.ts +39 -0
- package/dist/types/src/client/sandboxed/types/index.d.ts +2 -0
- package/dist/types/src/client/sandboxed/types/options.d.ts +27 -0
- package/dist/types/src/client/sandboxed/types/process.d.ts +39 -0
- package/dist/types/src/client/sandboxed/worker.d.ts +4 -0
- package/dist/types/src/client/sandboxed/wrapper.d.ts +12 -0
- package/dist/types/src/client/sandboxedWorker.d.ts +6 -0
- package/dist/types/src/client/tcp/client.d.ts +6 -0
- package/dist/types/src/client/tcp/commandQueue.d.ts +23 -0
- package/dist/types/src/client/tcp/connection.d.ts +4 -0
- package/dist/types/src/client/tcp/errors.d.ts +6 -0
- package/dist/types/src/client/tcp/health.d.ts +60 -0
- package/dist/types/src/client/tcp/index.d.ts +11 -0
- package/dist/types/src/client/tcp/reconnect.d.ts +47 -0
- package/dist/types/src/client/tcp/runtime/commands.d.ts +9 -0
- package/dist/types/src/client/tcp/runtime/connectivity.d.ts +13 -0
- package/dist/types/src/client/tcp/runtime/health.d.ts +14 -0
- package/dist/types/src/client/tcp/runtime/lifecycle.d.ts +8 -0
- package/dist/types/src/client/tcp/runtime/state.d.ts +50 -0
- package/dist/types/src/client/tcp/shared.d.ts +12 -0
- package/dist/types/src/client/tcp/transport.d.ts +18 -0
- package/dist/types/src/client/tcp/types/command.d.ts +9 -0
- package/dist/types/src/client/tcp/types/connection.d.ts +31 -0
- package/dist/types/src/client/tcp/types/index.d.ts +5 -0
- package/dist/types/src/client/tcp/types/socket.d.ts +8 -0
- package/dist/types/src/client/tcp/types/tls.d.ts +4 -0
- package/dist/types/src/client/tcp/types.d.ts +2 -0
- package/dist/types/src/client/tcpClient.d.ts +6 -0
- package/dist/types/src/client/tcpPool.d.ts +69 -0
- package/dist/types/src/client/types/connection.d.ts +30 -0
- package/dist/types/src/client/types/dlq.d.ts +45 -0
- package/dist/types/src/client/types/events.d.ts +54 -0
- package/dist/types/src/client/types/flow.d.ts +22 -0
- package/dist/types/src/client/types/index.d.ts +10 -0
- package/dist/types/src/client/types/job.d.ts +131 -0
- package/dist/types/src/client/types/metrics.d.ts +1 -0
- package/dist/types/src/client/types/options.d.ts +72 -0
- package/dist/types/src/client/types/worker.d.ts +54 -0
- package/dist/types/src/client/types.d.ts +2 -0
- package/dist/types/src/client/worker/ackBatcher.d.ts +55 -0
- package/dist/types/src/client/worker/ackFrontier.d.ts +21 -0
- package/dist/types/src/client/worker/ackOutcome.d.ts +8 -0
- package/dist/types/src/client/worker/batchExecution.d.ts +14 -0
- package/dist/types/src/client/worker/constants.d.ts +7 -0
- package/dist/types/src/client/worker/groupConcurrency.d.ts +49 -0
- package/dist/types/src/client/worker/handlers/completion.d.ts +29 -0
- package/dist/types/src/client/worker/handlers/dependencies.d.ts +11 -0
- package/dist/types/src/client/worker/handlers/mutations.d.ts +23 -0
- package/dist/types/src/client/worker/handlers/queries.d.ts +15 -0
- package/dist/types/src/client/worker/jobParser.d.ts +9 -0
- package/dist/types/src/client/worker/processor.d.ts +11 -0
- package/dist/types/src/client/worker/processorHandlers.d.ts +4 -0
- package/dist/types/src/client/worker/processorOutcome.d.ts +14 -0
- package/dist/types/src/client/worker/processorResult.d.ts +2 -0
- package/dist/types/src/client/worker/runtime/buffer.d.ts +8 -0
- package/dist/types/src/client/worker/runtime/control.d.ts +28 -0
- package/dist/types/src/client/worker/runtime/execution.d.ts +16 -0
- package/dist/types/src/client/worker/runtime/lifecycle.d.ts +7 -0
- package/dist/types/src/client/worker/runtime/manual.d.ts +10 -0
- package/dist/types/src/client/worker/runtime/options.d.ts +5 -0
- package/dist/types/src/client/worker/runtime/polling.d.ts +14 -0
- package/dist/types/src/client/worker/runtime/state.d.ts +121 -0
- package/dist/types/src/client/worker/types/index.d.ts +5 -0
- package/dist/types/src/client/worker/types/manual.d.ts +7 -0
- package/dist/types/src/client/worker/types/options.d.ts +26 -0
- package/dist/types/src/client/worker/types/outcome.d.ts +23 -0
- package/dist/types/src/client/worker/types/processor.d.ts +25 -0
- package/dist/types/src/client/worker/types/transport.d.ts +11 -0
- package/dist/types/src/client/worker/worker.d.ts +6 -0
- package/dist/types/src/client/worker/workerHeartbeat.d.ts +15 -0
- package/dist/types/src/client/worker/workerPull.d.ts +24 -0
- package/dist/types/src/client/worker/workerRateLimiter.d.ts +51 -0
- package/dist/types/src/client/worker.d.ts +6 -0
- package/dist/types/src/client/workflow/admission.d.ts +45 -0
- package/dist/types/src/client/workflow/clock.d.ts +60 -0
- package/dist/types/src/client/workflow/compensationChild.d.ts +33 -0
- package/dist/types/src/client/workflow/compensationClaim.d.ts +11 -0
- package/dist/types/src/client/workflow/compensationPass.d.ts +17 -0
- package/dist/types/src/client/workflow/compensationSupport.d.ts +24 -0
- package/dist/types/src/client/workflow/compensator.d.ts +34 -0
- package/dist/types/src/client/workflow/definitionGuard.d.ts +11 -0
- package/dist/types/src/client/workflow/emitter.d.ts +17 -0
- package/dist/types/src/client/workflow/engine.d.ts +66 -0
- package/dist/types/src/client/workflow/eventTypes.d.ts +44 -0
- package/dist/types/src/client/workflow/executionFence.d.ts +15 -0
- package/dist/types/src/client/workflow/executionTypes.d.ts +133 -0
- package/dist/types/src/client/workflow/executor.d.ts +52 -0
- package/dist/types/src/client/workflow/executorLifecycle.d.ts +19 -0
- package/dist/types/src/client/workflow/executorNodes.d.ts +18 -0
- package/dist/types/src/client/workflow/executorQueue.d.ts +9 -0
- package/dist/types/src/client/workflow/forEachRunner.d.ts +4 -0
- package/dist/types/src/client/workflow/identity.d.ts +48 -0
- package/dist/types/src/client/workflow/index.d.ts +23 -0
- package/dist/types/src/client/workflow/loops.d.ts +11 -0
- package/dist/types/src/client/workflow/mapRunner.d.ts +4 -0
- package/dist/types/src/client/workflow/recovery.d.ts +32 -0
- package/dist/types/src/client/workflow/rollbackControl.d.ts +37 -0
- package/dist/types/src/client/workflow/runner.d.ts +23 -0
- package/dist/types/src/client/workflow/runnerTiming.d.ts +14 -0
- package/dist/types/src/client/workflow/stepTypes.d.ts +171 -0
- package/dist/types/src/client/workflow/store.d.ts +83 -0
- package/dist/types/src/client/workflow/storeCodec.d.ts +7 -0
- package/dist/types/src/client/workflow/storeExecutionCodec.d.ts +11 -0
- package/dist/types/src/client/workflow/storeListing.d.ts +11 -0
- package/dist/types/src/client/workflow/storeMaintenance.d.ts +4 -0
- package/dist/types/src/client/workflow/storeSignals.d.ts +70 -0
- package/dist/types/src/client/workflow/subWorkflowRunner.d.ts +14 -0
- package/dist/types/src/client/workflow/types.d.ts +4 -0
- package/dist/types/src/client/workflow/unwindPlan.d.ts +87 -0
- package/dist/types/src/client/workflow/waitFor.d.ts +56 -0
- package/dist/types/src/client/workflow/workflow.d.ts +70 -0
- package/dist/types/src/client/workflow/workflowDecisions.d.ts +11 -0
- package/dist/types/src/client/workflow/workflowDefinition.d.ts +16 -0
- package/dist/types/src/client/workflow/workflowIntrospection.d.ts +5 -0
- package/dist/types/src/client/workflow/workflowValidation.d.ts +44 -0
- package/dist/types/src/config/index.d.ts +9 -0
- package/dist/types/src/config/loader.d.ts +7 -0
- package/dist/types/src/config/resolve.d.ts +59 -0
- package/dist/types/src/config/types.d.ts +88 -0
- package/dist/types/src/domain/job/constants.d.ts +14 -0
- package/dist/types/src/domain/job/create.d.ts +9 -0
- package/dist/types/src/domain/job/groupFifoOrder.d.ts +9 -0
- package/dist/types/src/domain/job/ids.d.ts +7 -0
- package/dist/types/src/domain/job/locks.d.ts +16 -0
- package/dist/types/src/domain/job/payload.d.ts +18 -0
- package/dist/types/src/domain/job/state.d.ts +23 -0
- package/dist/types/src/domain/job/terminal.d.ts +3 -0
- package/dist/types/src/domain/queue/dependencyTracker.d.ts +78 -0
- package/dist/types/src/domain/queue/dlqShard.d.ts +66 -0
- package/dist/types/src/domain/queue/groupLimiterManager.d.ts +30 -0
- package/dist/types/src/domain/queue/groupScheduler.d.ts +31 -0
- package/dist/types/src/domain/queue/groupSchedulerOrder.d.ts +6 -0
- package/dist/types/src/domain/queue/limiterManager.d.ts +68 -0
- package/dist/types/src/domain/queue/priorityQueue.d.ts +54 -0
- package/dist/types/src/domain/queue/priorityQueueOrder.d.ts +3 -0
- package/dist/types/src/domain/queue/shard/dependencies.d.ts +11 -0
- package/dist/types/src/domain/queue/shard/dlq.d.ts +26 -0
- package/dist/types/src/domain/queue/shard/keys.d.ts +19 -0
- package/dist/types/src/domain/queue/shard/lifecycle.d.ts +10 -0
- package/dist/types/src/domain/queue/shard/limits.d.ts +47 -0
- package/dist/types/src/domain/queue/shard/metrics.d.ts +32 -0
- package/dist/types/src/domain/queue/shard/state.d.ts +40 -0
- package/dist/types/src/domain/queue/shard.d.ts +7 -0
- package/dist/types/src/domain/queue/shardCounters.d.ts +35 -0
- package/dist/types/src/domain/queue/temporalIndex.d.ts +24 -0
- package/dist/types/src/domain/queue/temporalManager.d.ts +72 -0
- package/dist/types/src/domain/queue/uniqueKeyManager.d.ts +33 -0
- package/dist/types/src/domain/queue/waiterManager.d.ts +18 -0
- package/dist/types/src/domain/response/builders.d.ts +15 -0
- package/dist/types/src/domain/types/command.d.ts +2 -0
- package/dist/types/src/domain/types/commands/base.d.ts +5 -0
- package/dist/types/src/domain/types/commands/core.d.ts +107 -0
- package/dist/types/src/domain/types/commands/cron.d.ts +36 -0
- package/dist/types/src/domain/types/commands/dashboard.d.ts +13 -0
- package/dist/types/src/domain/types/commands/dlq.d.ts +44 -0
- package/dist/types/src/domain/types/commands/extended.d.ts +63 -0
- package/dist/types/src/domain/types/commands/index.d.ts +12 -0
- package/dist/types/src/domain/types/commands/limits.d.ts +108 -0
- package/dist/types/src/domain/types/commands/management.d.ts +73 -0
- package/dist/types/src/domain/types/commands/monitoring.d.ts +49 -0
- package/dist/types/src/domain/types/commands/protocol.d.ts +20 -0
- package/dist/types/src/domain/types/commands/query.d.ts +46 -0
- package/dist/types/src/domain/types/commands/union.d.ts +13 -0
- package/dist/types/src/domain/types/commands/workers.d.ts +39 -0
- package/dist/types/src/domain/types/cron.d.ts +89 -0
- package/dist/types/src/domain/types/deduplication.d.ts +43 -0
- package/dist/types/src/domain/types/dlq.d.ts +136 -0
- package/dist/types/src/domain/types/flow.d.ts +25 -0
- package/dist/types/src/domain/types/group.d.ts +26 -0
- package/dist/types/src/domain/types/job.d.ts +8 -0
- package/dist/types/src/domain/types/jobs/model.d.ts +150 -0
- package/dist/types/src/domain/types/metrics.d.ts +16 -0
- package/dist/types/src/domain/types/priorityQueue.d.ts +13 -0
- package/dist/types/src/domain/types/protocol.d.ts +5 -0
- package/dist/types/src/domain/types/queue.d.ts +110 -0
- package/dist/types/src/domain/types/response.d.ts +3 -0
- package/dist/types/src/domain/types/responses/model.d.ts +152 -0
- package/dist/types/src/domain/types/shard.d.ts +4 -0
- package/dist/types/src/domain/types/stall.d.ts +48 -0
- package/dist/types/src/domain/types/webhook.d.ts +42 -0
- package/dist/types/src/domain/types/worker.d.ts +40 -0
- package/dist/types/src/infrastructure/backup/backupTelemetry.d.ts +30 -0
- package/dist/types/src/infrastructure/backup/s3BackupConfig.d.ts +80 -0
- package/dist/types/src/infrastructure/cloud/types/config.d.ts +18 -0
- package/dist/types/src/infrastructure/cloud/types/event.d.ts +14 -0
- package/dist/types/src/infrastructure/cloud/types/snapshot.d.ts +52 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotCore.d.ts +125 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotJobs.d.ts +124 -0
- package/dist/types/src/infrastructure/cloud/types/snapshotTelemetry.d.ts +100 -0
- package/dist/types/src/infrastructure/cloud/types.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/batchInsert.d.ts +13 -0
- package/dist/types/src/infrastructure/persistence/completedJobCountSchema.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/dependencyCompletionSchema.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/dependencyCompletionStore.d.ts +40 -0
- package/dist/types/src/infrastructure/persistence/index.d.ts +5 -0
- package/dist/types/src/infrastructure/persistence/jobOptionsBlob.d.ts +19 -0
- package/dist/types/src/infrastructure/persistence/legacyNameMigration.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/migrationProgressSchema.d.ts +2 -0
- package/dist/types/src/infrastructure/persistence/migrations.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/schema.d.ts +8 -0
- package/dist/types/src/infrastructure/persistence/sqlite/admission.d.ts +9 -0
- package/dist/types/src/infrastructure/persistence/sqlite/completed.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/control.d.ts +48 -0
- package/dist/types/src/infrastructure/persistence/sqlite/flows.d.ts +26 -0
- package/dist/types/src/infrastructure/persistence/sqlite/jobLifecycle.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/jobs.d.ts +15 -0
- package/dist/types/src/infrastructure/persistence/sqlite/lifecycle.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/sqlite/mutations.d.ts +27 -0
- package/dist/types/src/infrastructure/persistence/sqlite/queries.d.ts +23 -0
- package/dist/types/src/infrastructure/persistence/sqlite/queueDeletionSql.d.ts +3 -0
- package/dist/types/src/infrastructure/persistence/sqlite/records.d.ts +24 -0
- package/dist/types/src/infrastructure/persistence/sqlite/state.d.ts +42 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetry.d.ts +17 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetryStore.d.ts +30 -0
- package/dist/types/src/infrastructure/persistence/sqlite/telemetryWrites.d.ts +47 -0
- package/dist/types/src/infrastructure/persistence/sqlite.d.ts +6 -0
- package/dist/types/src/infrastructure/persistence/sqliteBatch.d.ts +4 -0
- package/dist/types/src/infrastructure/persistence/sqliteMigration.d.ts +5 -0
- package/dist/types/src/infrastructure/persistence/sqliteSerializer.d.ts +50 -0
- package/dist/types/src/infrastructure/persistence/statements.d.ts +86 -0
- package/dist/types/src/infrastructure/persistence/types/admission.d.ts +8 -0
- package/dist/types/src/infrastructure/persistence/types/batch.d.ts +12 -0
- package/dist/types/src/infrastructure/persistence/types/sqlite.d.ts +27 -0
- package/dist/types/src/infrastructure/persistence/writeBuffer.d.ts +48 -0
- package/dist/types/src/infrastructure/persistence/writeBufferPending.d.ts +11 -0
- package/dist/types/src/infrastructure/scheduler/cron/execution.d.ts +12 -0
- package/dist/types/src/infrastructure/scheduler/cron/persisted.d.ts +5 -0
- package/dist/types/src/infrastructure/scheduler/cron/runtime.d.ts +31 -0
- package/dist/types/src/infrastructure/scheduler/cron/validation.d.ts +3 -0
- package/dist/types/src/infrastructure/scheduler/cronParser.d.ts +45 -0
- package/dist/types/src/infrastructure/scheduler/cronScheduler.d.ts +5 -0
- package/dist/types/src/infrastructure/scheduler/types/cronScheduler.d.ts +16 -0
- package/dist/types/src/infrastructure/server/protocol/commands.d.ts +8 -0
- package/dist/types/src/infrastructure/server/protocol/frameParser.d.ts +16 -0
- package/dist/types/src/infrastructure/server/protocol/lineBuffer.d.ts +6 -0
- package/dist/types/src/infrastructure/server/protocol/validation.d.ts +10 -0
- package/dist/types/src/infrastructure/server/protocol.d.ts +6 -0
- package/dist/types/src/infrastructure/server/socketWriteQueue.d.ts +66 -0
- package/dist/types/src/infrastructure/server/types/protocol.d.ts +4 -0
- package/dist/types/src/require-bun.d.ts +13 -0
- package/dist/types/src/shared/asyncLock.d.ts +13 -0
- package/dist/types/src/shared/boundedMap.d.ts +30 -0
- package/dist/types/src/shared/boundedSet.d.ts +26 -0
- package/dist/types/src/shared/hash.d.ts +30 -0
- package/dist/types/src/shared/histogram.d.ts +23 -0
- package/dist/types/src/shared/lock.d.ts +13 -0
- package/dist/types/src/shared/lockError.d.ts +3 -0
- package/dist/types/src/shared/lockTimeout.d.ts +2 -0
- package/dist/types/src/shared/logger.d.ts +48 -0
- package/dist/types/src/shared/lru.d.ts +9 -0
- package/dist/types/src/shared/lruMap.d.ts +42 -0
- package/dist/types/src/shared/lruSet.d.ts +36 -0
- package/dist/types/src/shared/minHeap.d.ts +43 -0
- package/dist/types/src/shared/msgpack.d.ts +3 -0
- package/dist/types/src/shared/pausedView.d.ts +19 -0
- package/dist/types/src/shared/rwLock.d.ts +22 -0
- package/dist/types/src/shared/serialization.d.ts +24 -0
- package/dist/types/src/shared/skipList.d.ts +97 -0
- package/dist/types/src/shared/skipListNodes.d.ts +6 -0
- package/dist/types/src/shared/storageHealth.d.ts +9 -0
- package/dist/types/src/shared/ttlMap.d.ts +81 -0
- package/dist/types/src/shared/types/lock.d.ts +7 -0
- package/dist/types/src/shared/types/skipList.d.ts +4 -0
- package/dist/types/src/shared/version.d.ts +4 -0
- package/dist/types/src/shared/webhookValidation.d.ts +6 -0
- package/package.json +27 -9
- package/src/ack-batcher.ts +8 -5
- package/src/bunqueue/bunqueue-api.ts +1 -1
- package/src/bunqueue/bunqueue.ts +2 -1
- package/src/canonical-transport/bun-sqlite-types.ts +22 -0
- package/src/canonical-transport/dlq.ts +12 -0
- package/src/canonical-transport/embedded.ts +55 -0
- package/src/canonical-transport/runtime.ts +49 -0
- package/src/canonical-transport/thread-worker.ts +83 -0
- package/src/canonical-transport/transport.ts +153 -0
- package/src/connection.ts +25 -30
- package/src/errors.ts +3 -0
- package/src/flow-commit.ts +45 -0
- package/src/flow-plan-legacy.ts +117 -0
- package/src/flow-plan.ts +209 -0
- package/src/flow-types.ts +4 -0
- package/src/flow.ts +31 -163
- package/src/frame.ts +5 -2
- package/src/index.ts +7 -75
- package/src/job.ts +43 -9
- package/src/legacy.ts +91 -0
- package/src/observability.ts +59 -1
- package/src/queue-admin.ts +5 -5
- package/src/queue-control.ts +8 -6
- package/src/queue.ts +10 -6
- package/src/serialization.ts +93 -0
- package/src/terminal-outcome.ts +58 -0
- package/src/types.ts +3 -6
- package/src/worker-base.ts +9 -6
- package/src/worker-slot-signal.ts +23 -0
- package/src/worker.ts +11 -5
- package/dist/backpressure.js +0 -39
- package/dist/bunqueue/aging.js +0 -53
- package/dist/bunqueue/batch.js +0 -60
- package/dist/bunqueue/bunqueue-api.js +0 -116
- package/dist/bunqueue/bunqueue.js +0 -194
- package/dist/bunqueue/cancellation.js +0 -48
- package/dist/bunqueue/circuit-breaker.js +0 -69
- package/dist/bunqueue/dedup-debounce.js +0 -37
- package/dist/bunqueue/dlq-rate-limit.js +0 -65
- package/dist/bunqueue/rate-gate.js +0 -61
- package/dist/bunqueue/retry.js +0 -56
- package/dist/bunqueue/triggers.js +0 -42
- package/dist/bunqueue/ttl.js +0 -31
- package/dist/bunqueue/types.js +0 -6
- package/dist/connection-pool.js +0 -60
- package/dist/connection-types.js +0 -2
- package/dist/connection.js +0 -281
- package/dist/errors.js +0 -25
- package/dist/flow-types.js +0 -2
- package/dist/flow.js +0 -212
- package/dist/job.js +0 -155
- package/dist/observability.js +0 -110
- package/dist/queue-admin.js +0 -158
- package/dist/queue-control.js +0 -107
- package/dist/queue-query.js +0 -187
- package/dist/queue.js +0 -92
- package/dist/responses.js +0 -10
- package/dist/socket-factory.js +0 -47
- package/dist/types.js +0 -50
- package/dist/worker-base.js +0 -159
- package/dist/worker-types.js +0 -5
- package/dist/worker.js +0 -211
- /package/dist/{backpressure.d.ts → types/sdk/typescript/src/backpressure.d.ts} +0 -0
- /package/dist/{bunqueue → types/sdk/typescript/src/bunqueue}/cancellation.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,171 @@ All notable changes to `bunqueue-client` (TypeScript SDK) are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.1] - 2026-10-02
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Ships the bunqueue 2.9.7 engine and client fixes this package compiles in
|
|
13
|
+
(they apply to embedded mode and to the canonical Queue/Worker classes):
|
|
14
|
+
periodic cleanup no longer drops active jobs that are still sending
|
|
15
|
+
heartbeats or renewing their lock; orphan recovery goes through the stall
|
|
16
|
+
path and releases the concurrency slot, group slot and unique key; recovery
|
|
17
|
+
sweeps act only on the current delivery; `backoff.maxDelay` is kept on job
|
|
18
|
+
creation and caps retry delays; `DelayedError` honors `backoff.maxDelay`,
|
|
19
|
+
and TCP workers keep the backoff configuration the server sends.
|
|
20
|
+
- `BackoffOptions` accepts `maxDelay`, so `backoff: { type, delay, maxDelay }`
|
|
21
|
+
type-checks.
|
|
22
|
+
|
|
23
|
+
## [0.2.0] - 2026-10-01
|
|
24
|
+
|
|
25
|
+
### BREAKING CHANGES
|
|
26
|
+
|
|
27
|
+
This is a breaking minor release. Follow the
|
|
28
|
+
[migration guide](./README.md#migrating-from-01x), or switch the import to
|
|
29
|
+
`bunqueue-client/legacy`, which keeps the 0.1.x API unchanged.
|
|
30
|
+
|
|
31
|
+
- The default `bunqueue-client` entry is now the canonical `bunqueue/client`
|
|
32
|
+
API (see Changed below); the 0.1.x API moved to `bunqueue-client/legacy`.
|
|
33
|
+
- Connection settings must be passed as `connection: { host, port, token, tls }`.
|
|
34
|
+
Top-level `host`, `port`, `token`, or `tls` now throw an `Error` naming the
|
|
35
|
+
keys, in `Queue`, `Worker`, `FlowProducer`, `QueueEvents`, `Bunqueue`,
|
|
36
|
+
`SandboxedWorker`, `QueueGroup.getQueue()/getWorker()`, and the workflow
|
|
37
|
+
`Engine`, instead of silently connecting to `localhost:6789` without the
|
|
38
|
+
token or TLS.
|
|
39
|
+
- In TCP mode `pause()`, `resume()`, `drain()`, `obliterate()`, `remove()`,
|
|
40
|
+
and the synchronous rate-limit, concurrency, stall, and DLQ setters send
|
|
41
|
+
their command without waiting for the broker. Await `pauseAsync()`,
|
|
42
|
+
`resumeAsync()`, `drainAsync()`, `obliterateAsync()`, `removeAsync()`, and
|
|
43
|
+
the other `*Async` variants before enqueuing follow-up work.
|
|
44
|
+
- Synchronous reads (`isPaused()`, `count()`, `getJobs()`, `getWaiting()` and
|
|
45
|
+
the other state lists, `getCountsPerPriority()`, `getDlq()`, `getDlqStats()`,
|
|
46
|
+
`getStallConfig()`, `getDlqConfig()`, `clean()`) are embedded-only and return
|
|
47
|
+
defaults in TCP mode; use their `*Async` variants. `getJobCounts()` returns
|
|
48
|
+
a `Promise` in TCP mode.
|
|
49
|
+
- `Job` is exported as a type only (`import type { Job }`); there is no `Job`
|
|
50
|
+
constructor and no `job.raw`.
|
|
51
|
+
- Removed type exports: `BunqueueConnection`, `TlsOption`, `BackoffOptions`,
|
|
52
|
+
`DeduplicationOptions`, `RepeatOptions`, `SchedulerOptions`, `FlowOptions`,
|
|
53
|
+
`GetFlowOptions`, `BulkJobEntry`, `JobCounts`, `JobStateName`, `JobRaw`,
|
|
54
|
+
`CircuitState`, `TelemetryErrorOperation`, `WorkerEventMap`,
|
|
55
|
+
`AckBatchOptions`, `Command`, `Response`, and the `*Response` wire types.
|
|
56
|
+
The migration guide lists each replacement.
|
|
57
|
+
- `AuthError`, `BunqueueError`, `CommandError`, `CommandTimeoutError`,
|
|
58
|
+
`ConnectionClosedError`, and `SerializationError` remain exported for the
|
|
59
|
+
low-level `Connection`/`ConnectionPool`, but `Queue`, `Worker`,
|
|
60
|
+
`FlowProducer`, and `QueueEvents` reject with plain `Error` instances.
|
|
61
|
+
- `@types/node` is no longer installed with the package. The declarations
|
|
62
|
+
import `events` and `node:net`, so TypeScript consumers must provide
|
|
63
|
+
`@types/node` themselves (20 or newer), including Workers projects that
|
|
64
|
+
type-check with `skipLibCheck: false`.
|
|
65
|
+
- After any client `close()`, an unhandled rejection in your application is
|
|
66
|
+
no longer swallowed: without your own `unhandledRejection` handler the
|
|
67
|
+
process reports it and exits with code 1, as Bun and Node do by default.
|
|
68
|
+
|
|
69
|
+
### Changed
|
|
70
|
+
|
|
71
|
+
- The default entry now uses the canonical Bun client implementation and
|
|
72
|
+
public types. Queue/Worker/Job behavior, defaults, events, groups, batches,
|
|
73
|
+
dependency helpers, and Async methods share one source across packages.
|
|
74
|
+
Historical flat-option SDK APIs remain available at `bunqueue-client/legacy`.
|
|
75
|
+
- Builds reject stale source/artifact manifests and any public type/API drift.
|
|
76
|
+
Shared native contracts and generated histories exercise the compiled SDK;
|
|
77
|
+
Bun, Node 20/22, Deno, protocol conformance, and Workers are release gates.
|
|
78
|
+
- Portable TCP/TLS and worker-thread adapters replace runtime I/O only. The
|
|
79
|
+
real embedded backend is loaded under Bun and remains Bun-only.
|
|
80
|
+
|
|
81
|
+
### Removed
|
|
82
|
+
|
|
83
|
+
- Removed the StrykerJS mutation gate, its `stryker.config.mjs` configuration
|
|
84
|
+
and the `test:mutation` script. The engine's transitive dependencies were the
|
|
85
|
+
only source of this package's advisory findings and never reached published
|
|
86
|
+
code; the pure planners and snapshot validator stay covered by the fast-check
|
|
87
|
+
campaigns in `bun run test:property`. The published runtime dependency set is
|
|
88
|
+
unchanged (`msgpackr` only).
|
|
89
|
+
|
|
90
|
+
### Added
|
|
91
|
+
|
|
92
|
+
- Add independent-connection idempotency and single-lease race tests,
|
|
93
|
+
fixed-seed generated payload invariants, malformed mutation fuzzing, and an
|
|
94
|
+
opt-in sustained producer profile.
|
|
95
|
+
|
|
96
|
+
### Fixed
|
|
97
|
+
|
|
98
|
+
- A command issued before the broker listens now waits for the canonical
|
|
99
|
+
reconnect under Node, Deno, and Workers, as it does under Bun. The portable
|
|
100
|
+
transport reported every refused connection attempt as a lost connection,
|
|
101
|
+
which rejected queued commands with `Connection lost` within milliseconds
|
|
102
|
+
and made Workers emit repeated errors.
|
|
103
|
+
- The published JavaScript no longer uses top-level `await`, so CommonJS
|
|
104
|
+
bundlers such as `esbuild --bundle --format=cjs` accept it again. Under Bun
|
|
105
|
+
the embedded engine now loads synchronously on first embedded use; Node,
|
|
106
|
+
Deno, and Workers still never load it.
|
|
107
|
+
- The published declarations no longer reference `bun-types`, Bun globals, or
|
|
108
|
+
`bun:sqlite`, and `bun-types`/`@types/node` are no longer runtime
|
|
109
|
+
dependencies. Strict NodeNext projects with `@types/node` 20 or 22 now
|
|
110
|
+
type-check with `skipLibCheck: false` (with or without the DOM library), and
|
|
111
|
+
`Bun` is no longer declared in Node projects. The build fails if a Bun or
|
|
112
|
+
DOM-only type reaches the published declaration graph again.
|
|
113
|
+
- Wake the saturated Worker pull loop when an ACK or FAIL releases a
|
|
114
|
+
concurrency slot, retaining the existing 20 ms fallback while avoiding a
|
|
115
|
+
full polling delay between completion waves.
|
|
116
|
+
- Treat broker-authoritative late `ACK`/`FAIL` outcomes as ignored rather than
|
|
117
|
+
locally completed or failed. Batched ACKs now use `ignoredIndices`, so
|
|
118
|
+
duplicate job IDs are settled by input position without false events or
|
|
119
|
+
counter increments.
|
|
120
|
+
- Forward a Worker-owned Job's lease token through `retry()`, `changeDelay()`,
|
|
121
|
+
`moveToDelayed()`, and `discard()`, and accept the token on the matching Queue
|
|
122
|
+
mutation methods. Active transitions now satisfy broker ownership instead
|
|
123
|
+
of failing, silently leaving the job active, or allowing an old delivery to
|
|
124
|
+
discard a newer generation.
|
|
125
|
+
- Negotiate wire protocol v3 and advertise the `separate-job-name`
|
|
126
|
+
capability in `Hello`.
|
|
127
|
+
- Send `PUSH`/`PUSHB` names through top-level `name`, preserve user `data`
|
|
128
|
+
without wrapping or reserving `data.name`, decode legacy envelopes on read,
|
|
129
|
+
and send scheduler job names through `jobName`.
|
|
130
|
+
- Forward the optional `duration` from `setGlobalRateLimit(max, duration)` to
|
|
131
|
+
the broker instead of silently applying the one-second default.
|
|
132
|
+
- Let the operating system allocate an independent HTTP port for every E2E
|
|
133
|
+
broker fixture, preventing nested auth and restart fixtures from colliding
|
|
134
|
+
with an adjacent TCP listener.
|
|
135
|
+
- Emit dependency-free, typed, sanitized `error` telemetry for connection,
|
|
136
|
+
socket, write, and serialization failures without forwarding raw error
|
|
137
|
+
messages, tokens, commands, or payloads.
|
|
138
|
+
- Reject MessagePack payloads larger than the protocol's 64 MiB frame cap
|
|
139
|
+
locally with `SerializationError`, before allocating or writing the framed
|
|
140
|
+
buffer.
|
|
141
|
+
- Normalize MessagePack encoder failures to `SerializationError` and serialize
|
|
142
|
+
commands before registering their timer, pending entry, or backpressure slot,
|
|
143
|
+
preventing malformed commands from reducing connection capacity.
|
|
144
|
+
- Validate command values recursively: reject `BigInt`, non-string map keys,
|
|
145
|
+
cycles, non-finite numbers, accessors, symbols, functions, and non-portable
|
|
146
|
+
object types while retaining standard objects, arrays, dates, and binary.
|
|
147
|
+
|
|
148
|
+
## [0.1.10] - 2026-07-30
|
|
149
|
+
|
|
150
|
+
Never published to npm; these changes first ship in 0.2.0.
|
|
151
|
+
|
|
152
|
+
### Added
|
|
153
|
+
|
|
154
|
+
- Add deterministic fast-check campaigns for generated flow trees, shrinking,
|
|
155
|
+
ID uniqueness, graph closure, reciprocal links, shape isomorphism, option
|
|
156
|
+
forwarding, chain/fan-in topology, and broker snapshot validation.
|
|
157
|
+
- Add a Stryker mutation gate scoped to the pure tree/legacy planners and
|
|
158
|
+
snapshot validator, plus explicit Cloudflare Workers coverage for generated
|
|
159
|
+
portable IDs.
|
|
160
|
+
|
|
161
|
+
### Fixed
|
|
162
|
+
|
|
163
|
+
- Compile trees, bulk trees, chains, and fan-in graphs with all IDs preallocated
|
|
164
|
+
and commit them through one broker-side atomic `PUSHF` command. Partial
|
|
165
|
+
`PUSH`/`UpdateParent` graphs and best-effort rollback are no longer possible.
|
|
166
|
+
- Map public `jobId` to the planned ID and wire `customId`, reject unsupported
|
|
167
|
+
repeat/deduplication/debounce and caller-owned topology, protect internal data
|
|
168
|
+
markers, reject `jobId` queue defaults, and reject nested children in flat
|
|
169
|
+
flow methods.
|
|
170
|
+
- Validate the exact returned snapshot ID/queue set and build every public
|
|
171
|
+
`FlowNode` from those committed snapshots.
|
|
172
|
+
|
|
8
173
|
## [0.1.9] - 2026-07-14
|
|
9
174
|
|
|
10
175
|
Conformance-suite driven: the SDK is now certified by the cross-language
|
package/LEGACY.md
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
> This document describes the compatibility entry `bunqueue-client/legacy`. For the canonical client, use [README.md](./README.md).
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<a href="https://bunqueue.dev">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/egeominotti/bunqueue/main/.github/logo.png" alt="bunqueue logo" width="110" />
|
|
7
|
+
</a>
|
|
8
|
+
|
|
9
|
+
# bunqueue-client
|
|
10
|
+
|
|
11
|
+
**The official TypeScript client for [bunqueue](https://bunqueue.dev), the high performance job queue server.**
|
|
12
|
+
|
|
13
|
+
Native TCP protocol (msgpack, pipelined), the historical SDK compatibility API, one runtime dependency.
|
|
14
|
+
Runs everywhere: Node.js, Bun, Deno and Cloudflare Workers.
|
|
15
|
+
|
|
16
|
+
[](https://www.npmjs.com/package/bunqueue-client)
|
|
17
|
+
[](https://www.npmjs.com/package/bunqueue-client)
|
|
18
|
+
[](https://github.com/egeominotti/bunqueue/blob/main/sdk/typescript/LICENSE)
|
|
19
|
+
[](#compatibility)
|
|
20
|
+
[](https://github.com/egeominotti/bunqueue/tree/main/sdk/conformance)
|
|
21
|
+
|
|
22
|
+
[Documentation](https://bunqueue.dev/guide/sdks/) · [Protocol spec](https://github.com/egeominotti/bunqueue/blob/main/docs/protocol.md) · [Server](https://github.com/egeominotti/bunqueue) · [Changelog](https://github.com/egeominotti/bunqueue/blob/main/sdk/typescript/CHANGELOG.md)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
The bunqueue server runs on Bun, distributed as a binary or a Docker image. This client allows any Node.js, Bun, Deno, or Cloudflare Workers service to produce and consume jobs against it: one queue, any language, any runtime.
|
|
29
|
+
|
|
30
|
+
## Why bunqueue-client
|
|
31
|
+
|
|
32
|
+
- **Full API surface.** Queues, workers, flows (parent/children trees), schedulers, DLQ, rate limits, webhooks, Simple Mode: 110+ public methods, each covered by an e2e test against a real server.
|
|
33
|
+
- **Cross runtime by design.** Only `node:*` builtins, zero `Bun.*` globals, a single dependency (`msgpackr`). The same package runs on Node 20+, Bun, Deno 2 and Cloudflare Workers (`nodejs_compat`).
|
|
34
|
+
- **Production semantics.** Lock leasing with heartbeat renewal, at least once delivery with retries and backoff, unrecoverable failures straight to the DLQ, reconnection with half open detection, opt in ACK batching and connection pooling.
|
|
35
|
+
- **Typed end to end.** Generic `Queue<T>` / `Worker<T, R>`, typed worker events, structured telemetry hooks for your metrics stack.
|
|
36
|
+
|
|
37
|
+
## Compatibility
|
|
38
|
+
|
|
39
|
+
| Runtime | Status | Notes |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| Node.js 20 or later | Supported, 116/116 e2e and 10/10 integration tests | ESM. TypeScript files run directly on Node 22 or later via `--experimental-strip-types` |
|
|
42
|
+
| Bun | Supported, 116/116 e2e and 10/10 integration tests | No additional configuration required |
|
|
43
|
+
| Deno 2 or later | Supported, 116/116 e2e and 10/10 integration tests | Uses `node:` builtins and the npm `msgpackr` package |
|
|
44
|
+
| tsx, ts-node, vitest, jest | Supported | These environments execute on Node.js |
|
|
45
|
+
| Cloudflare Workers | Supported, 16/16 e2e tests inside workerd, including Simple Mode and the full API surface | Requires the `nodejs_compat` compatibility flag. The runtime is request scoped, so long lived worker loops are not available: consume in batches from Cron Triggers or Durable Object alarms, a pattern covered by the test suite. TLS connections require a publicly trusted certificate |
|
|
46
|
+
| Browser | Not supported | Raw TCP sockets are unavailable. Use the server HTTP API instead |
|
|
47
|
+
|
|
48
|
+
Portability is guaranteed by design: the client relies exclusively on `node:*` builtins (`net`, `tls`, `events`, `crypto`, `os`), uses no `Bun.*` globals and no runtime specific imports, and carries a single runtime dependency, `msgpackr`.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install bunqueue-client
|
|
54
|
+
# or: bun add bunqueue-client / pnpm add bunqueue-client / deno add npm:bunqueue-client
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick start, step by step
|
|
58
|
+
|
|
59
|
+
Every step from zero to a production ready queue.
|
|
60
|
+
|
|
61
|
+
### Step 1. Run the bunqueue server
|
|
62
|
+
|
|
63
|
+
The server is the only component that requires [Bun](https://bun.sh). Pick one:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Option A: one command, no install (requires Bun)
|
|
67
|
+
bunx bunqueue start
|
|
68
|
+
|
|
69
|
+
# Option B: Docker, with persistent data
|
|
70
|
+
docker run -d --name bunqueue \
|
|
71
|
+
-p 6789:6789 -p 6790:6790 \
|
|
72
|
+
-v bunqueue-data:/app/data \
|
|
73
|
+
ghcr.io/egeominotti/bunqueue:latest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Port 6789 is the TCP protocol (what this client uses), port 6790 is the HTTP API with `/health`, `/metrics`, and dashboard endpoints.
|
|
77
|
+
|
|
78
|
+
### Step 2. Install the client
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install bunqueue-client
|
|
82
|
+
# or: bun add bunqueue-client / pnpm add bunqueue-client / deno add npm:bunqueue-client
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 3. Add your first job and process it
|
|
86
|
+
|
|
87
|
+
Create `app.ts`, one file for the sake of the demo:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { Queue, Worker } from 'bunqueue-client/legacy';
|
|
91
|
+
|
|
92
|
+
const worker = new Worker('hello', async (job) => {
|
|
93
|
+
console.log('processing', job.data);
|
|
94
|
+
return { greeted: job.data.name };
|
|
95
|
+
});
|
|
96
|
+
worker.on('completed', (job, result) => {
|
|
97
|
+
console.log('completed', job.id, result);
|
|
98
|
+
worker.close();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const queue = new Queue('hello');
|
|
102
|
+
await queue.add('greet', { name: 'world' });
|
|
103
|
+
queue.close();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Run it with the runtime you already use:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
node --experimental-strip-types app.ts # Node 22 or later
|
|
110
|
+
bun app.ts # Bun
|
|
111
|
+
deno run -A app.ts # Deno 2 or later
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Expected output:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
processing { name: 'world' }
|
|
118
|
+
completed 019f40a5-... { greeted: 'world' }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The operation name and user payload are independent: this job has
|
|
122
|
+
`job.name === 'greet'` while `job.data.name === 'world'`. Objects, arrays,
|
|
123
|
+
scalars, and null are sent as `data` without wrapping; readers still decode
|
|
124
|
+
jobs written by clients that used the legacy `data.name` envelope. Scheduler
|
|
125
|
+
templates follow the same rule through their distinct `jobName` field.
|
|
126
|
+
The client negotiates protocol v3 and advertises `separate-job-name` in `Hello`.
|
|
127
|
+
|
|
128
|
+
Defaults are `host: 'localhost'` and `port: 6789`, so constructors need no options on a local setup.
|
|
129
|
+
|
|
130
|
+
### Step 4. Split producer and worker
|
|
131
|
+
|
|
132
|
+
In production the producer and the worker are separate services, often in different languages. The producer is typically an API endpoint:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// api-service: adds jobs, no processing
|
|
136
|
+
import { Queue } from 'bunqueue-client/legacy';
|
|
137
|
+
const queue = new Queue('emails', { host: 'queue.internal', port: 6789 });
|
|
138
|
+
await queue.add('welcome', { to: 'user@example.com' }, { attempts: 3 });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The worker is a long running process:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// worker-service: processes jobs, no HTTP
|
|
145
|
+
import { Worker } from 'bunqueue-client/legacy';
|
|
146
|
+
new Worker('emails', sendEmail, { host: 'queue.internal', port: 6789, concurrency: 10 });
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The [Python client](https://github.com/egeominotti/bunqueue/tree/main/sdk/python) speaks the same protocol against the same queue, so the worker can be a Python service instead.
|
|
150
|
+
|
|
151
|
+
### Step 5. Observe and operate
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
await queue.getJobCounts(); // { waiting, active, completed, failed, delayed, ... }
|
|
155
|
+
await queue.getDlq(); // jobs that exhausted their retries
|
|
156
|
+
await queue.retryDlq(); // send them back to the queue
|
|
157
|
+
await queue.getWorkers(); // connected workers
|
|
158
|
+
await queue.getStats(); // throughput and totals
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Or hit the HTTP side: `curl http://localhost:6790/health`.
|
|
162
|
+
|
|
163
|
+
### Step 6. Go to production
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
const queue = new Queue('emails', {
|
|
167
|
+
host: 'queue.example.com',
|
|
168
|
+
port: 6789,
|
|
169
|
+
token: process.env.BUNQUEUE_TOKEN, // server started with AUTH_TOKENS=...
|
|
170
|
+
tls: true, // or { caFile: './ca.pem' }
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Checklist: set `AUTH_TOKENS` on the server, enable TLS (`TLS_CERT_FILE`/`TLS_KEY_FILE`), mount a volume for the SQLite data path, monitor `/health` and `/metrics`, and size worker `concurrency` to your workload. Full guide: [bunqueue.dev/guide/deployment](https://bunqueue.dev/guide/deployment/).
|
|
175
|
+
|
|
176
|
+
## Producing jobs
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { Queue } from 'bunqueue-client/legacy';
|
|
180
|
+
|
|
181
|
+
const queue = new Queue('emails', { host: 'localhost', port: 6789 });
|
|
182
|
+
|
|
183
|
+
await queue.add('send', { to: 'user@example.com' }, { priority: 5, attempts: 3 });
|
|
184
|
+
await queue.addBulk([
|
|
185
|
+
{ name: 'send', data: { to: 'a@b.c' } },
|
|
186
|
+
{ name: 'send', data: { to: 'x@y.z' }, opts: { delay: 5000 } },
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
const counts = await queue.getJobCounts();
|
|
190
|
+
queue.close();
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Processing jobs
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { Worker, UnrecoverableError } from 'bunqueue-client/legacy';
|
|
197
|
+
|
|
198
|
+
const worker = new Worker(
|
|
199
|
+
'emails',
|
|
200
|
+
async (job) => {
|
|
201
|
+
await job.updateProgress(50);
|
|
202
|
+
if (job.data.invalid) throw new UnrecoverableError('bad payload'); // no retries, straight to the DLQ
|
|
203
|
+
return { sent: true };
|
|
204
|
+
},
|
|
205
|
+
{ host: 'localhost', port: 6789, concurrency: 10 }
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
worker.on('completed', (job, result) => console.log(job.id, result));
|
|
209
|
+
worker.on('failed', (job, err) => console.error(job.id, err.message));
|
|
210
|
+
|
|
211
|
+
// later: await worker.close(); // graceful shutdown, waits for in flight jobs
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Retry, backoff, dead letter queue, stall detection, priorities, and rate limiting all execute server side. The worker only pulls, heartbeats, and acknowledges, which keeps the client thin and the behavior consistent across languages.
|
|
215
|
+
|
|
216
|
+
## Flows
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import { FlowProducer } from 'bunqueue-client/legacy';
|
|
220
|
+
|
|
221
|
+
const flow = new FlowProducer({ host: 'localhost', port: 6789 });
|
|
222
|
+
|
|
223
|
+
// sequential chain: step1, then step2, then step3
|
|
224
|
+
await flow.addChain([
|
|
225
|
+
{ name: 'step1', queueName: 'pipeline' },
|
|
226
|
+
{ name: 'step2', queueName: 'pipeline' },
|
|
227
|
+
{ name: 'step3', queueName: 'pipeline' },
|
|
228
|
+
]);
|
|
229
|
+
|
|
230
|
+
// fan in: parallel jobs converge into a final job that reads their results
|
|
231
|
+
const { finalId } = await flow.addBulkThen(
|
|
232
|
+
[
|
|
233
|
+
{ name: 'part1', queueName: 'pipeline' },
|
|
234
|
+
{ name: 'part2', queueName: 'pipeline' },
|
|
235
|
+
],
|
|
236
|
+
{ name: 'merge', queueName: 'pipeline' }
|
|
237
|
+
);
|
|
238
|
+
// inside the 'merge' processor: await job.getChildrenValues()
|
|
239
|
+
|
|
240
|
+
// parent and child tree: children always run before the parent
|
|
241
|
+
const node = await flow.add({
|
|
242
|
+
name: 'assemble',
|
|
243
|
+
queueName: 'orders',
|
|
244
|
+
opts: { jobId: 'order-42-assembly' },
|
|
245
|
+
children: [
|
|
246
|
+
{
|
|
247
|
+
name: 'reserve-stock',
|
|
248
|
+
queueName: 'orders',
|
|
249
|
+
opts: { jobId: 'order-42-stock' },
|
|
250
|
+
},
|
|
251
|
+
{ name: 'charge-card', queueName: 'orders' },
|
|
252
|
+
],
|
|
253
|
+
}, {
|
|
254
|
+
queuesOptions: { orders: { attempts: 3, backoff: 500 } },
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
console.log(node.job.id); // order-42-assembly
|
|
258
|
+
console.log(node.children?.[0].job.id); // order-42-stock
|
|
259
|
+
flow.close();
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
`add`, `addBulk`, `addChain`, and `addBulkThen` compile the complete dependency
|
|
263
|
+
graph locally, preallocate every ID, and send exactly one `PUSHF` command. The
|
|
264
|
+
broker either persists and publishes the entire graph or creates no jobs. The
|
|
265
|
+
returned `Job` objects are built from the broker's committed snapshots, so
|
|
266
|
+
state, options, and reciprocal parent/child links are immediately available.
|
|
267
|
+
|
|
268
|
+
`opts.jobId` becomes both the planned ID and the wire `customId`; generated IDs
|
|
269
|
+
are portable UUIDs and never contain `:`. Atomic flows reject `repeat`,
|
|
270
|
+
`deduplication`, and `debounce`, because those options can change graph
|
|
271
|
+
cardinality or identity. `parentId`, `dependsOn`, and `childrenIds` are owned
|
|
272
|
+
by the planner. Job data keys named `name` or beginning with `__` are reserved
|
|
273
|
+
for immutable flow metadata and are rejected instead of being overwritten.
|
|
274
|
+
`queuesOptions` may define scheduling and retention defaults, but not
|
|
275
|
+
`jobId`; identity is always chosen on the individual node.
|
|
276
|
+
|
|
277
|
+
A transport timeout after `PUSHF` is ambiguous: the broker may have committed
|
|
278
|
+
the complete graph before the response was lost. Assign a deterministic
|
|
279
|
+
`opts.jobId` to every node and reuse the same graph on retry. If the first call
|
|
280
|
+
did not commit, the retry can create it; if it did, strict `PUSHF` collision
|
|
281
|
+
checking returns `already exists` instead of rewriting the graph or fabricating
|
|
282
|
+
snapshots. Treat that error as a reconciliation signal and query the known
|
|
283
|
+
stable IDs. Regenerated IDs can create a second graph after an uncertain
|
|
284
|
+
outcome.
|
|
285
|
+
|
|
286
|
+
## Simple Mode
|
|
287
|
+
|
|
288
|
+
`Bunqueue` bundles a Queue and a Worker in one object, with routes, onion middleware, in process retry strategies, a circuit breaker, batch accumulation, event triggers, job TTL, priority aging, cooperative cancellation, and dedup or debounce defaults. It is a 1:1 port of the official client's Simple Mode, TCP only (the `embedded` option raises).
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import { Bunqueue, type Job } from 'bunqueue-client/legacy';
|
|
292
|
+
|
|
293
|
+
const app = new Bunqueue('notifications', {
|
|
294
|
+
connection: { host: 'localhost', port: 6789 },
|
|
295
|
+
concurrency: 10,
|
|
296
|
+
routes: {
|
|
297
|
+
'send-email': async (job: Job<{ to: string }>) => ({ channel: 'email' }),
|
|
298
|
+
'send-sms': async (job: Job<{ to: string }>) => ({ channel: 'sms' }),
|
|
299
|
+
},
|
|
300
|
+
retry: { maxAttempts: 5, delay: 1000, strategy: 'jitter' },
|
|
301
|
+
circuitBreaker: { threshold: 5, resetTimeout: 30_000 },
|
|
302
|
+
ttl: { perName: { 'verify-otp': 60_000 } },
|
|
303
|
+
deduplication: { ttl: 5000 },
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
app.use(async (job, next) => {
|
|
307
|
+
const start = Date.now();
|
|
308
|
+
const result = await next();
|
|
309
|
+
console.log(`${job.name}: ${Date.now() - start}ms`);
|
|
310
|
+
return result;
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
app.trigger({
|
|
314
|
+
on: 'send-email',
|
|
315
|
+
create: 'send-sms',
|
|
316
|
+
data: (result, job) => job.data,
|
|
317
|
+
condition: (result) => (result as { channel: string }).channel === 'email',
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
await app.cron('daily-digest', '0 9 * * *', { to: 'all' });
|
|
321
|
+
await app.add('send-email', { to: 'alice@example.com' });
|
|
322
|
+
// later: await app.close();
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Use `processor` for a single handler, `routes` to dispatch by job name, or `batch` to accumulate N jobs into one call. Exactly one of the three is required.
|
|
326
|
+
|
|
327
|
+
## Scheduling
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
await queue.addCron('daily-report', '0 9 * * *', { type: 'report' });
|
|
331
|
+
await queue.every('health-ping', 30_000, { type: 'ping' });
|
|
332
|
+
await queue.removeJobScheduler('daily-report');
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Security
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
const queue = new Queue('emails', {
|
|
339
|
+
host: 'queue.example.com',
|
|
340
|
+
port: 6789,
|
|
341
|
+
token: process.env.BUNQUEUE_TOKEN,
|
|
342
|
+
tls: { caFile: './ca.pem' }, // or `true` for system certificate authorities
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Authentication uses server side tokens (`AUTH_TOKENS`). Transport security uses native TLS, with support for system certificate authorities, a custom CA bundle, or disabled verification for development environments.
|
|
347
|
+
|
|
348
|
+
## Observability
|
|
349
|
+
|
|
350
|
+
Inject a logger and a telemetry sink to bridge the client into your stack. There are no hard dependencies — you wire OpenTelemetry, Prometheus or your own logger. Defaults are silent.
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
import { Queue, consoleLogger, type TelemetryEvent } from 'bunqueue-client/legacy';
|
|
354
|
+
|
|
355
|
+
const queue = new Queue('emails', {
|
|
356
|
+
logger: consoleLogger('info'), // or your own { debug, info, warn, error }
|
|
357
|
+
onTelemetry: (e: TelemetryEvent) => {
|
|
358
|
+
// command latency, lifecycle, auth, backpressure and sanitized errors
|
|
359
|
+
if (e.type === 'command') metrics.observe(e.cmd, e.durationMs, e.ok);
|
|
360
|
+
if (e.type === 'error') metrics.increment(`bunqueue.${e.operation}.errors`);
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// Connection is an EventEmitter for lifecycle hooks:
|
|
365
|
+
queue.connection.on('reconnect_scheduled', (i) => log.warn('reconnecting', i));
|
|
366
|
+
queue.connection.on('disconnect', () => log.warn('link down'));
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
`error` telemetry covers connect, socket, write, and serialization failures.
|
|
370
|
+
Its `message`, `errorType`, and optional system `code` are safe metadata: raw
|
|
371
|
+
error messages, authentication tokens, commands, and payloads are never sent to
|
|
372
|
+
the telemetry callback. Telemetry and logger callback failures are isolated
|
|
373
|
+
from transport operations.
|
|
374
|
+
|
|
375
|
+
## Throughput and resilience
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
// Bound in-flight commands (backpressure) — parks callers instead of growing memory:
|
|
379
|
+
const queue = new Queue('emails', { maxInFlight: 10_000 });
|
|
380
|
+
|
|
381
|
+
// Fan producer commands across N connections (round-robin, producer-side):
|
|
382
|
+
const pooled = new Queue('emails', { poolSize: 4 });
|
|
383
|
+
|
|
384
|
+
// Batch worker ACKs into ACKB round-trips (opt-in) for high-volume consumers:
|
|
385
|
+
const worker = new Worker('emails', process, {
|
|
386
|
+
ackBatch: { enabled: true, maxSize: 50, maxDelayMs: 5 },
|
|
387
|
+
});
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Worker terminal events are broker-authoritative. If a timeout or retired cron
|
|
391
|
+
generation finalizes a lease while the processor is still returning, the
|
|
392
|
+
broker accepts the late `ACK` or `FAIL` as an ignored outcome and the Worker
|
|
393
|
+
emits neither `completed` nor `failed`. Batched ACKs apply that decision by
|
|
394
|
+
input position, including batches that contain the same job ID more than once.
|
|
395
|
+
Worker-owned `job.discard()` sends the same delivery token as ACK/FAIL, so an
|
|
396
|
+
older processor cannot discard a newer active generation.
|
|
397
|
+
|
|
398
|
+
Always attach a `worker.on('error', …)` listener: per Node `EventEmitter` semantics an unhandled `error` event throws. The worker frees each job's concurrency slot before emitting, so even a throwing listener cannot degrade throughput — but the error itself is yours to observe.
|
|
399
|
+
|
|
400
|
+
Half-open links are detected via TCP keepalive and a consecutive-timeout teardown, so a silently dropped connection (cloud LB/NAT idle drop) recovers in seconds rather than minutes.
|
|
401
|
+
|
|
402
|
+
Malformed or oversized commands reject with `SerializationError` before they
|
|
403
|
+
occupy an in-flight slot or write to the socket. This keeps bounded connections
|
|
404
|
+
usable after a local MessagePack encoding failure. Payloads may contain plain
|
|
405
|
+
objects, arrays, string-keyed maps, valid dates, and binary values; `BigInt`,
|
|
406
|
+
cycles, non-string map keys, symbols, functions, accessors, non-finite numbers,
|
|
407
|
+
and custom object types are rejected as non-portable.
|
|
408
|
+
|
|
409
|
+
## Typed responses
|
|
410
|
+
|
|
411
|
+
`connection.call<R>()` and `queue.call<R>()` are generic over the exported response shapes (`JobResponse`, `PulledJobsResponse`, `JobCountsResponse`, `WaitJobResponse`, …), so raw command access is fully typed without casting.
|
|
412
|
+
|
|
413
|
+
## API surface
|
|
414
|
+
|
|
415
|
+
| Area | Capabilities |
|
|
416
|
+
|---|---|
|
|
417
|
+
| Queue | `add`, `addBulk`, full `JobOptions`: priority, delay, attempts, backoff, ttl, timeout, jobId, deduplication, dependsOn, tags, groupId, lifo, removeOnComplete, removeOnFail, durable, repeat, debounce |
|
|
418
|
+
| Query | `getJob`, `getJobByCustomId`, `getJobs` with per state helpers, state, result, progress, `waitForJob` (throws on timeout, BullMQ contract), counts, counts per priority, children values, job logs |
|
|
419
|
+
| Control | pause, resume, drain, obliterate, clean, remove, discard, promote, `retryJob`, `retryJobs`, move to wait or delayed, change priority or delay, update data, extend lock |
|
|
420
|
+
| Dead letter queue | `getDlq`, `retryDlq`, `purgeDlq`, DLQ configuration |
|
|
421
|
+
| Administration | rate limiting with custom windows (`setGlobalRateLimit(max, duration)`), global concurrency, stall configuration, webhooks, stats, metrics, `listQueues`, `getWorkers` |
|
|
422
|
+
| Worker events | `ready`, `active`, `completed`, `failed`, `progress`, `drained`, `error`, `closed`, with automatic lock heartbeats so that jobs longer than the lock TTL survive |
|
|
423
|
+
| Simple Mode | `Bunqueue`: routes, middleware, in process retry (fixed, exponential, jitter, fibonacci, custom), circuit breaker, batch accumulation, triggers, TTL, priority aging, cancellation via `getSignal`, dedup and debounce defaults, cron shorthands |
|
|
424
|
+
|
|
425
|
+
The following features require the in process Bun runtime and are intentionally out of scope for this client: embedded mode, sandboxed workers, and `QueueEvents`. Use webhooks or the HTTP SSE and WebSocket endpoints for event streaming.
|
|
426
|
+
|
|
427
|
+
Note on numeric payloads: JavaScript numbers are IEEE 754 doubles, exact up to 2^53. Pass larger 64 bit identifiers, for example snowflake IDs, as strings to avoid silent precision loss. Never place `BigInt` values in job data.
|
|
428
|
+
|
|
429
|
+
## Quality assurance
|
|
430
|
+
|
|
431
|
+
Every release is validated against a real bunqueue server, spawned fresh for each run, across every supported runtime:
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
bun install
|
|
435
|
+
bun run build # tsc, emits dist/
|
|
436
|
+
bun run check # Oxlint and Oxfmt verification
|
|
437
|
+
BUNQUEUE_FLOW_PBT_SEED=20260730 bun run test:property
|
|
438
|
+
|
|
439
|
+
bun tests/integration.ts # smoke suite
|
|
440
|
+
bun tests/e2e.ts # full surface, edge cases, realistic load
|
|
441
|
+
node --experimental-strip-types tests/e2e.ts # identical suite on Node 22 or later
|
|
442
|
+
deno run -A tests/e2e.ts # identical suite on Deno 2 or later
|
|
443
|
+
bun run test:workers # full suite inside workerd, the Cloudflare Workers runtime
|
|
444
|
+
BUNQUEUE_SDK_SOAK_SECONDS=3600 bun run test:soak # opt-in sustained connection profile
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
The e2e suite includes payload limits, unicode integrity, pipelining under
|
|
448
|
+
concurrency, 24-way idempotent retries, 12-way single-lease contention,
|
|
449
|
+
fixed-seed generated payloads, malformed mutation fuzzing, a 1500-job spike,
|
|
450
|
+
server crash/restart, and realistic zero-loss accounting. `test:soak` reuses
|
|
451
|
+
one pooled client; tune `BUNQUEUE_SDK_SOAK_BATCH` for stress diagnostics.
|
|
452
|
+
Engineering standards: Oxlint and Oxfmt, a maximum of 250 lines per file, and
|
|
453
|
+
relative imports with explicit `.js` extensions for NodeNext resolution.
|
|
454
|
+
Maintainers should read the [runtime invariants](INVARIANTS.md), the
|
|
455
|
+
[module and protocol guide](CLAUDE.md), and the
|
|
456
|
+
[local agent rules](AGENTS.md) before changing behavior.
|
|
457
|
+
|
|
458
|
+
## License
|
|
459
|
+
|
|
460
|
+
MIT. See the [LICENSE](./LICENSE) file. Documentation: [bunqueue.dev/guide/sdks](https://bunqueue.dev/guide/sdks/). Issues and feature requests: [GitHub issues](https://github.com/egeominotti/bunqueue/issues).
|