bunqueue 2.8.60 → 2.9.2
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/README.md +114 -78
- package/dist/application/background/dlq.js +2 -0
- package/dist/application/background/recovery/active.d.ts +1 -0
- package/dist/application/background/recovery/active.js +12 -0
- package/dist/application/background/recovery/index.js +3 -1
- package/dist/application/background/recovery/pending.js +1 -0
- package/dist/application/cleanupTasks.js +4 -16
- package/dist/application/contextFactory.js +8 -0
- package/dist/application/dlqManager.d.ts +10 -0
- package/dist/application/dlqManager.js +48 -9
- package/dist/application/dlqRetry.js +60 -38
- package/dist/application/eventsManager.d.ts +9 -2
- package/dist/application/eventsManager.js +106 -55
- package/dist/application/operations/ackHelpers.d.ts +1 -4
- package/dist/application/operations/ackHelpers.js +39 -14
- package/dist/application/operations/flowPush.js +1 -0
- package/dist/application/operations/flowValidation.js +4 -4
- package/dist/application/operations/jobManagement.d.ts +4 -0
- package/dist/application/operations/jobMoveOperations.js +9 -4
- package/dist/application/operations/pull.d.ts +7 -2
- package/dist/application/operations/pull.js +15 -57
- package/dist/application/operations/pullFinalization.d.ts +6 -0
- package/dist/application/operations/pullFinalization.js +69 -0
- package/dist/application/operations/pullStateTransition.d.ts +8 -7
- package/dist/application/operations/pullStateTransition.js +25 -18
- package/dist/application/operations/push.js +3 -0
- package/dist/application/operations/pushBatch.js +14 -7
- package/dist/application/operations/pushContext.d.ts +2 -1
- package/dist/application/postgres-queue-manager/batchSnapshot.d.ts +16 -0
- package/dist/application/postgres-queue-manager/batchSnapshot.js +17 -0
- package/dist/application/postgres-queue-manager/cloud.d.ts +30 -0
- package/dist/application/postgres-queue-manager/cloud.js +55 -0
- package/dist/application/postgres-queue-manager/config.d.ts +5 -0
- package/dist/application/postgres-queue-manager/config.js +1 -0
- package/dist/application/postgres-queue-manager/control.d.ts +30 -0
- package/dist/application/postgres-queue-manager/control.js +210 -0
- package/dist/application/postgres-queue-manager/deferredWrites.d.ts +13 -0
- package/dist/application/postgres-queue-manager/deferredWrites.js +60 -0
- package/dist/application/postgres-queue-manager/delivery.d.ts +20 -0
- package/dist/application/postgres-queue-manager/delivery.js +83 -0
- package/dist/application/postgres-queue-manager/groupQueries.d.ts +10 -0
- package/dist/application/postgres-queue-manager/groupQueries.js +40 -0
- package/dist/application/postgres-queue-manager/lease.d.ts +13 -0
- package/dist/application/postgres-queue-manager/lease.js +88 -0
- package/dist/application/postgres-queue-manager/lifetimeMetrics.d.ts +32 -0
- package/dist/application/postgres-queue-manager/lifetimeMetrics.js +53 -0
- package/dist/application/postgres-queue-manager/maintenance.d.ts +14 -0
- package/dist/application/postgres-queue-manager/maintenance.js +100 -0
- package/dist/application/postgres-queue-manager/operationGate.d.ts +26 -0
- package/dist/application/postgres-queue-manager/operationGate.js +96 -0
- package/dist/application/postgres-queue-manager/operations.d.ts +25 -0
- package/dist/application/postgres-queue-manager/operations.js +194 -0
- package/dist/application/postgres-queue-manager/projectionRefreshes.d.ts +43 -0
- package/dist/application/postgres-queue-manager/projectionRefreshes.js +170 -0
- package/dist/application/postgres-queue-manager/queries.d.ts +142 -0
- package/dist/application/postgres-queue-manager/queries.js +231 -0
- package/dist/application/postgres-queue-manager/relationships.d.ts +10 -0
- package/dist/application/postgres-queue-manager/relationships.js +45 -0
- package/dist/application/postgres-queue-manager/services.d.ts +31 -0
- package/dist/application/postgres-queue-manager/services.js +149 -0
- package/dist/application/postgres-queue-manager/snapshot.d.ts +51 -0
- package/dist/application/postgres-queue-manager/snapshot.js +236 -0
- package/dist/application/postgres-queue-manager/snapshotViews.d.ts +15 -0
- package/dist/application/postgres-queue-manager/snapshotViews.js +100 -0
- package/dist/application/postgres-queue-manager/startupEventBuffer.d.ts +12 -0
- package/dist/application/postgres-queue-manager/startupEventBuffer.js +36 -0
- package/dist/application/postgres-queue-manager/state.d.ts +47 -0
- package/dist/application/postgres-queue-manager/state.js +273 -0
- package/dist/application/postgres-queue-manager/terminalDelivery.d.ts +20 -0
- package/dist/application/postgres-queue-manager/terminalDelivery.js +100 -0
- package/dist/application/postgresQueueManager.d.ts +2 -0
- package/dist/application/postgresQueueManager.js +1 -0
- package/dist/application/queue-manager/control.js +1 -0
- package/dist/application/queue-manager/delivery.d.ts +5 -4
- package/dist/application/queue-manager/delivery.js +15 -8
- package/dist/application/queue-manager/flow-failures.js +4 -0
- package/dist/application/queue-manager/limits.d.ts +13 -0
- package/dist/application/queue-manager/limits.js +65 -0
- package/dist/application/queue-manager/observability.js +15 -3
- package/dist/application/queue-manager/queries.d.ts +7 -0
- package/dist/application/queue-manager/queries.js +9 -0
- package/dist/application/queue-manager/services.d.ts +1 -1
- package/dist/application/queue-manager/services.js +4 -2
- package/dist/application/queue-manager/state.js +17 -2
- package/dist/application/queueTelemetryJournal.d.ts +2 -0
- package/dist/application/queueTelemetryJournal.js +23 -0
- package/dist/application/types/ack.d.ts +3 -1
- package/dist/cli/commandRouter.d.ts +1 -1
- package/dist/cli/commands/server.js +1 -1
- package/dist/client/flowPush.js +6 -0
- package/dist/client/forwarder.d.ts +6 -4
- package/dist/client/forwarder.js +5 -3
- package/dist/client/groupId.d.ts +1 -0
- package/dist/client/groupId.js +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/jobHelpers.js +1 -0
- package/dist/client/queue/dlq.d.ts +2 -0
- package/dist/client/queue/dlq.js +14 -0
- package/dist/client/queue/dlqOps.d.ts +2 -0
- package/dist/client/queue/dlqOps.js +4 -0
- package/dist/client/queue/helpers.js +2 -0
- package/dist/client/queue/operations/add/bulk.js +4 -4
- package/dist/client/queue/operations/add/payload.d.ts +1 -0
- package/dist/client/queue/operations/add/payload.js +7 -1
- package/dist/client/queue/operations/add/single.js +3 -3
- package/dist/client/queue/operations/groups.d.ts +21 -0
- package/dist/client/queue/operations/groups.js +88 -0
- package/dist/client/queue/runtime/configuration.d.ts +4 -0
- package/dist/client/queue/runtime/configuration.js +8 -0
- package/dist/client/queue/runtime/queries.d.ts +13 -0
- package/dist/client/queue/runtime/queries.js +31 -0
- package/dist/client/queue/runtime/state.d.ts +4 -0
- package/dist/client/queue/runtime/state.js +1 -0
- package/dist/client/types/index.d.ts +2 -2
- package/dist/client/types/options.d.ts +4 -0
- package/dist/client/types/worker.d.ts +8 -0
- package/dist/client/worker/runtime/execution.js +4 -8
- package/dist/client/worker/runtime/options.js +3 -0
- package/dist/client/worker/runtime/polling.d.ts +1 -0
- package/dist/client/worker/runtime/polling.js +9 -0
- package/dist/client/worker/types/options.d.ts +2 -1
- package/dist/client/worker/workerPull.d.ts +2 -0
- package/dist/client/worker/workerPull.js +6 -4
- package/dist/config/resolve.d.ts +14 -0
- package/dist/config/resolve.js +50 -5
- package/dist/config/types.d.ts +18 -0
- package/dist/domain/job/groupFifoOrder.d.ts +9 -0
- package/dist/domain/job/groupFifoOrder.js +26 -0
- package/dist/domain/queue/dlqShard.d.ts +2 -0
- package/dist/domain/queue/dlqShard.js +16 -0
- package/dist/domain/queue/groupLimiterManager.d.ts +23 -0
- package/dist/domain/queue/groupLimiterManager.js +107 -0
- package/dist/domain/queue/groupScheduler.d.ts +31 -0
- package/dist/domain/queue/groupScheduler.js +256 -0
- package/dist/domain/queue/groupSchedulerOrder.d.ts +6 -0
- package/dist/domain/queue/groupSchedulerOrder.js +30 -0
- package/dist/domain/queue/priorityQueue.d.ts +13 -23
- package/dist/domain/queue/priorityQueue.js +53 -42
- package/dist/domain/queue/shard/dlq.d.ts +1 -0
- package/dist/domain/queue/shard/dlq.js +3 -0
- package/dist/domain/queue/shard/keys.d.ts +1 -0
- package/dist/domain/queue/shard/keys.js +25 -2
- package/dist/domain/queue/shard/lifecycle.js +4 -0
- package/dist/domain/queue/shard/limits.d.ts +20 -1
- package/dist/domain/queue/shard/limits.js +56 -0
- package/dist/domain/queue/shard/state.d.ts +5 -0
- package/dist/domain/queue/shard/state.js +9 -1
- package/dist/domain/types/commands/core.d.ts +3 -0
- package/dist/domain/types/commands/dlq.d.ts +5 -0
- package/dist/domain/types/commands/limits.d.ts +41 -0
- package/dist/domain/types/commands/union.d.ts +1 -1
- package/dist/domain/types/cron.d.ts +5 -0
- package/dist/domain/types/cron.js +14 -3
- package/dist/domain/types/dlq.d.ts +1 -1
- package/dist/domain/types/dlq.js +1 -2
- package/dist/domain/types/group.d.ts +21 -0
- package/dist/domain/types/group.js +78 -0
- package/dist/domain/types/jobs/model.d.ts +1 -1
- package/dist/domain/types/priorityQueue.d.ts +1 -0
- package/dist/infrastructure/cloud/commandHandler.js +5 -3
- package/dist/infrastructure/cloud/commands/integrations.js +11 -11
- package/dist/infrastructure/cloud/commands/jobs.js +48 -40
- package/dist/infrastructure/cloud/commands/queues.js +61 -75
- package/dist/infrastructure/cloud/queueAdapter/local.d.ts +41 -0
- package/dist/infrastructure/cloud/queueAdapter/local.js +187 -0
- package/dist/infrastructure/cloud/queueAdapter/postgres.d.ts +42 -0
- package/dist/infrastructure/cloud/queueAdapter/postgres.js +188 -0
- package/dist/infrastructure/cloud/queueAdapter/registry.d.ts +4 -0
- package/dist/infrastructure/cloud/queueAdapter/registry.js +15 -0
- package/dist/infrastructure/cloud/queueAdapter/types.d.ts +87 -0
- package/dist/infrastructure/cloud/queueAdapter/types.js +1 -0
- package/dist/infrastructure/cloud/snapshot/analytics.d.ts +2 -0
- package/dist/infrastructure/cloud/snapshot/analytics.js +7 -0
- package/dist/infrastructure/cloud/snapshot/collector.d.ts +4 -0
- package/dist/infrastructure/cloud/snapshot/collector.js +39 -1
- package/dist/infrastructure/cloud/snapshot/config.d.ts +3 -0
- package/dist/infrastructure/cloud/snapshot/config.js +43 -0
- package/dist/infrastructure/cloud/snapshot/jobs.d.ts +3 -0
- package/dist/infrastructure/cloud/snapshot/jobs.js +32 -1
- package/dist/infrastructure/cloud/snapshotCollector.js +20 -35
- package/dist/infrastructure/cloud/snapshotHelpers.d.ts +3 -3
- package/dist/infrastructure/cloud/snapshotHelpers.js +3 -3
- package/dist/infrastructure/cloud/statsRefresh.js +2 -1
- package/dist/infrastructure/cloud/types/command.d.ts +2 -2
- package/dist/infrastructure/persistence/jobOptionsBlob.d.ts +1 -0
- package/dist/infrastructure/persistence/jobOptionsBlob.js +10 -2
- package/dist/infrastructure/persistence/migrations.js +11 -0
- package/dist/infrastructure/persistence/postgres/admission.d.ts +18 -0
- package/dist/infrastructure/persistence/postgres/admission.js +196 -0
- package/dist/infrastructure/persistence/postgres/admissionParent.d.ts +5 -0
- package/dist/infrastructure/persistence/postgres/admissionParent.js +35 -0
- package/dist/infrastructure/persistence/postgres/admissionResult.d.ts +9 -0
- package/dist/infrastructure/persistence/postgres/admissionResult.js +1 -0
- package/dist/infrastructure/persistence/postgres/admissionStore.d.ts +12 -0
- package/dist/infrastructure/persistence/postgres/admissionStore.js +101 -0
- package/dist/infrastructure/persistence/postgres/advisoryLocks.d.ts +2 -0
- package/dist/infrastructure/persistence/postgres/advisoryLocks.js +13 -0
- package/dist/infrastructure/persistence/postgres/batchAdmission.d.ts +11 -0
- package/dist/infrastructure/persistence/postgres/batchAdmission.js +128 -0
- package/dist/infrastructure/persistence/postgres/batchCompletion.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/batchCompletion.js +174 -0
- package/dist/infrastructure/persistence/postgres/batchEvents.d.ts +14 -0
- package/dist/infrastructure/persistence/postgres/batchEvents.js +72 -0
- package/dist/infrastructure/persistence/postgres/brokerSessions.d.ts +14 -0
- package/dist/infrastructure/persistence/postgres/brokerSessions.js +94 -0
- package/dist/infrastructure/persistence/postgres/claimBatch.d.ts +14 -0
- package/dist/infrastructure/persistence/postgres/claimBatch.js +69 -0
- package/dist/infrastructure/persistence/postgres/claimSelection.d.ts +11 -0
- package/dist/infrastructure/persistence/postgres/claimSelection.js +140 -0
- package/dist/infrastructure/persistence/postgres/claims.d.ts +10 -0
- package/dist/infrastructure/persistence/postgres/claims.js +153 -0
- package/dist/infrastructure/persistence/postgres/cloudReadModel.d.ts +26 -0
- package/dist/infrastructure/persistence/postgres/cloudReadModel.js +123 -0
- package/dist/infrastructure/persistence/postgres/codec.d.ts +30 -0
- package/dist/infrastructure/persistence/postgres/codec.js +82 -0
- package/dist/infrastructure/persistence/postgres/completionEvents.d.ts +11 -0
- package/dist/infrastructure/persistence/postgres/completionEvents.js +21 -0
- package/dist/infrastructure/persistence/postgres/completionLifecycle.d.ts +11 -0
- package/dist/infrastructure/persistence/postgres/completionLifecycle.js +145 -0
- package/dist/infrastructure/persistence/postgres/completionOutcome.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/completionOutcome.js +112 -0
- package/dist/infrastructure/persistence/postgres/completionQueries.d.ts +10 -0
- package/dist/infrastructure/persistence/postgres/completionQueries.js +87 -0
- package/dist/infrastructure/persistence/postgres/connection.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/connection.js +15 -0
- package/dist/infrastructure/persistence/postgres/context.d.ts +28 -0
- package/dist/infrastructure/persistence/postgres/context.js +74 -0
- package/dist/infrastructure/persistence/postgres/control.d.ts +23 -0
- package/dist/infrastructure/persistence/postgres/control.js +105 -0
- package/dist/infrastructure/persistence/postgres/crons.d.ts +18 -0
- package/dist/infrastructure/persistence/postgres/crons.js +205 -0
- package/dist/infrastructure/persistence/postgres/deduplication.d.ts +9 -0
- package/dist/infrastructure/persistence/postgres/deduplication.js +47 -0
- package/dist/infrastructure/persistence/postgres/dependencyDestruction.d.ts +14 -0
- package/dist/infrastructure/persistence/postgres/dependencyDestruction.js +74 -0
- package/dist/infrastructure/persistence/postgres/dependencyPromotion.d.ts +29 -0
- package/dist/infrastructure/persistence/postgres/dependencyPromotion.js +212 -0
- package/dist/infrastructure/persistence/postgres/destructiveMutations.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/destructiveMutations.js +111 -0
- package/dist/infrastructure/persistence/postgres/dlqLifecycle.d.ts +13 -0
- package/dist/infrastructure/persistence/postgres/dlqLifecycle.js +184 -0
- package/dist/infrastructure/persistence/postgres/dlqMaintenance.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/dlqMaintenance.js +36 -0
- package/dist/infrastructure/persistence/postgres/dlqRetryPlan.d.ts +21 -0
- package/dist/infrastructure/persistence/postgres/dlqRetryPlan.js +92 -0
- package/dist/infrastructure/persistence/postgres/eventCatchupCursors.d.ts +32 -0
- package/dist/infrastructure/persistence/postgres/eventCatchupCursors.js +66 -0
- package/dist/infrastructure/persistence/postgres/eventCommitGc.d.ts +27 -0
- package/dist/infrastructure/persistence/postgres/eventCommitGc.js +62 -0
- package/dist/infrastructure/persistence/postgres/eventJournal.d.ts +18 -0
- package/dist/infrastructure/persistence/postgres/eventJournal.js +76 -0
- package/dist/infrastructure/persistence/postgres/eventJournalSchema.d.ts +5 -0
- package/dist/infrastructure/persistence/postgres/eventJournalSchema.js +267 -0
- package/dist/infrastructure/persistence/postgres/eventPruneWatermarks.d.ts +26 -0
- package/dist/infrastructure/persistence/postgres/eventPruneWatermarks.js +129 -0
- package/dist/infrastructure/persistence/postgres/eventRetention.d.ts +18 -0
- package/dist/infrastructure/persistence/postgres/eventRetention.js +76 -0
- package/dist/infrastructure/persistence/postgres/events.d.ts +45 -0
- package/dist/infrastructure/persistence/postgres/events.js +276 -0
- package/dist/infrastructure/persistence/postgres/expiry.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/expiry.js +74 -0
- package/dist/infrastructure/persistence/postgres/flowFailures.d.ts +17 -0
- package/dist/infrastructure/persistence/postgres/flowFailures.js +199 -0
- package/dist/infrastructure/persistence/postgres/groupClaims.d.ts +15 -0
- package/dist/infrastructure/persistence/postgres/groupClaims.js +95 -0
- package/dist/infrastructure/persistence/postgres/groupSchema.d.ts +2 -0
- package/dist/infrastructure/persistence/postgres/groupSchema.js +155 -0
- package/dist/infrastructure/persistence/postgres/groupSchemaFingerprint.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/groupSchemaFingerprint.js +127 -0
- package/dist/infrastructure/persistence/postgres/groupStateRetention.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/groupStateRetention.js +93 -0
- package/dist/infrastructure/persistence/postgres/groups.d.ts +11 -0
- package/dist/infrastructure/persistence/postgres/groups.js +117 -0
- package/dist/infrastructure/persistence/postgres/jobData.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/jobData.js +32 -0
- package/dist/infrastructure/persistence/postgres/leaseRelease.d.ts +9 -0
- package/dist/infrastructure/persistence/postgres/leaseRelease.js +120 -0
- package/dist/infrastructure/persistence/postgres/leaseRenewal.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/leaseRenewal.js +35 -0
- package/dist/infrastructure/persistence/postgres/lifetimeMetrics.d.ts +15 -0
- package/dist/infrastructure/persistence/postgres/lifetimeMetrics.js +46 -0
- package/dist/infrastructure/persistence/postgres/lifetimeMetricsFinalizer.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/lifetimeMetricsFinalizer.js +13 -0
- package/dist/infrastructure/persistence/postgres/logs.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/logs.js +70 -0
- package/dist/infrastructure/persistence/postgres/maintenance.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/maintenance.js +138 -0
- package/dist/infrastructure/persistence/postgres/maintenanceFlights.d.ts +14 -0
- package/dist/infrastructure/persistence/postgres/maintenanceFlights.js +66 -0
- package/dist/infrastructure/persistence/postgres/metricWrites.d.ts +9 -0
- package/dist/infrastructure/persistence/postgres/metricWrites.js +94 -0
- package/dist/infrastructure/persistence/postgres/mutations.d.ts +9 -0
- package/dist/infrastructure/persistence/postgres/mutations.js +171 -0
- package/dist/infrastructure/persistence/postgres/outcomes.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/outcomes.js +194 -0
- package/dist/infrastructure/persistence/postgres/policies.d.ts +11 -0
- package/dist/infrastructure/persistence/postgres/policies.js +18 -0
- package/dist/infrastructure/persistence/postgres/postCommitMaintenance.d.ts +17 -0
- package/dist/infrastructure/persistence/postgres/postCommitMaintenance.js +117 -0
- package/dist/infrastructure/persistence/postgres/promotion.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/promotion.js +43 -0
- package/dist/infrastructure/persistence/postgres/queries.d.ts +22 -0
- package/dist/infrastructure/persistence/postgres/queries.js +152 -0
- package/dist/infrastructure/persistence/postgres/queueDestruction.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/queueDestruction.js +158 -0
- package/dist/infrastructure/persistence/postgres/queueLifecycle.d.ts +10 -0
- package/dist/infrastructure/persistence/postgres/queueLifecycle.js +60 -0
- package/dist/infrastructure/persistence/postgres/rateLimit.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/rateLimit.js +10 -0
- package/dist/infrastructure/persistence/postgres/readModels.d.ts +32 -0
- package/dist/infrastructure/persistence/postgres/readModels.js +72 -0
- package/dist/infrastructure/persistence/postgres/recovery.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/recovery.js +178 -0
- package/dist/infrastructure/persistence/postgres/relationships.d.ts +9 -0
- package/dist/infrastructure/persistence/postgres/relationships.js +201 -0
- package/dist/infrastructure/persistence/postgres/removeUnprocessedChildren.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/removeUnprocessedChildren.js +241 -0
- package/dist/infrastructure/persistence/postgres/repeatMutations.d.ts +5 -0
- package/dist/infrastructure/persistence/postgres/repeatMutations.js +37 -0
- package/dist/infrastructure/persistence/postgres/runtime.d.ts +45 -0
- package/dist/infrastructure/persistence/postgres/runtime.js +238 -0
- package/dist/infrastructure/persistence/postgres/runtimeConfig.d.ts +21 -0
- package/dist/infrastructure/persistence/postgres/runtimeConfig.js +39 -0
- package/dist/infrastructure/persistence/postgres/schema.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/schema.js +261 -0
- package/dist/infrastructure/persistence/postgres/schemaInitialization.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/schemaInitialization.js +226 -0
- package/dist/infrastructure/persistence/postgres/serialAdmission.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/serialAdmission.js +96 -0
- package/dist/infrastructure/persistence/postgres/snapshotBudget.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/snapshotBudget.js +83 -0
- package/dist/infrastructure/persistence/postgres/storageHealth.d.ts +10 -0
- package/dist/infrastructure/persistence/postgres/storageHealth.js +29 -0
- package/dist/infrastructure/persistence/postgres/store.d.ts +100 -0
- package/dist/infrastructure/persistence/postgres/store.js +180 -0
- package/dist/infrastructure/persistence/postgres/telemetry.d.ts +8 -0
- package/dist/infrastructure/persistence/postgres/telemetry.js +100 -0
- package/dist/infrastructure/persistence/postgres/terminal.d.ts +8 -0
- package/dist/infrastructure/persistence/postgres/terminal.js +137 -0
- package/dist/infrastructure/persistence/postgres/transactionRetry.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/transactionRetry.js +42 -0
- package/dist/infrastructure/persistence/postgres/types.d.ts +176 -0
- package/dist/infrastructure/persistence/postgres/types.js +1 -0
- package/dist/infrastructure/persistence/postgres/workers.d.ts +15 -0
- package/dist/infrastructure/persistence/postgres/workers.js +126 -0
- package/dist/infrastructure/persistence/postgres.d.ts +2 -0
- package/dist/infrastructure/persistence/postgres.js +1 -0
- package/dist/infrastructure/persistence/schema.d.ts +2 -2
- package/dist/infrastructure/persistence/schema.js +12 -1
- package/dist/infrastructure/persistence/sqlite/control.d.ts +14 -0
- package/dist/infrastructure/persistence/sqlite/control.js +69 -0
- package/dist/infrastructure/persistence/sqlite/jobs.d.ts +12 -0
- package/dist/infrastructure/persistence/sqlite/jobs.js +38 -0
- package/dist/infrastructure/persistence/sqlite/telemetry.d.ts +2 -1
- package/dist/infrastructure/persistence/sqlite/telemetry.js +5 -64
- package/dist/infrastructure/persistence/sqlite/telemetryWrites.d.ts +4 -0
- package/dist/infrastructure/persistence/sqlite/telemetryWrites.js +123 -0
- package/dist/infrastructure/persistence/sqliteSerializer.js +2 -0
- package/dist/infrastructure/scheduler/cron/persisted.d.ts +5 -0
- package/dist/infrastructure/scheduler/cron/persisted.js +27 -0
- package/dist/infrastructure/scheduler/cron/runtime.js +5 -10
- package/dist/infrastructure/scheduler/cron/validation.d.ts +3 -0
- package/dist/infrastructure/scheduler/cron/validation.js +11 -0
- package/dist/infrastructure/scheduler/cronParser.d.ts +1 -1
- package/dist/infrastructure/scheduler/cronParser.js +144 -11
- package/dist/infrastructure/server/bootstrap.d.ts +2 -3
- package/dist/infrastructure/server/bootstrap.js +33 -59
- package/dist/infrastructure/server/errors.d.ts +4 -0
- package/dist/infrastructure/server/errors.js +54 -0
- package/dist/infrastructure/server/handler-routes/control.d.ts +5 -5
- package/dist/infrastructure/server/handler-routes/control.js +16 -1
- package/dist/infrastructure/server/handler-routes/monitoring.d.ts +2 -2
- package/dist/infrastructure/server/handler.js +9 -11
- package/dist/infrastructure/server/handlers/advanced/dependencies.js +7 -6
- package/dist/infrastructure/server/handlers/advanced/jobs.js +19 -6
- package/dist/infrastructure/server/handlers/advanced/queue.d.ts +9 -9
- package/dist/infrastructure/server/handlers/advanced/queue.js +91 -27
- package/dist/infrastructure/server/handlers/core.d.ts +0 -5
- package/dist/infrastructure/server/handlers/core.js +47 -49
- package/dist/infrastructure/server/handlers/cron.d.ts +4 -4
- package/dist/infrastructure/server/handlers/cron.js +60 -59
- package/dist/infrastructure/server/handlers/dashboard.d.ts +1 -1
- package/dist/infrastructure/server/handlers/dashboard.js +21 -8
- package/dist/infrastructure/server/handlers/dlq.d.ts +6 -3
- package/dist/infrastructure/server/handlers/dlq.js +35 -9
- package/dist/infrastructure/server/handlers/flow.js +2 -1
- package/dist/infrastructure/server/handlers/groups.d.ts +11 -0
- package/dist/infrastructure/server/handlers/groups.js +55 -0
- package/dist/infrastructure/server/handlers/management.d.ts +5 -5
- package/dist/infrastructure/server/handlers/management.js +36 -9
- package/dist/infrastructure/server/handlers/monitoring/health.d.ts +5 -5
- package/dist/infrastructure/server/handlers/monitoring/health.js +45 -16
- package/dist/infrastructure/server/handlers/monitoring/operations.d.ts +1 -1
- package/dist/infrastructure/server/handlers/monitoring/operations.js +8 -1
- package/dist/infrastructure/server/handlers/monitoring/workers.d.ts +3 -3
- package/dist/infrastructure/server/handlers/monitoring/workers.js +31 -7
- package/dist/infrastructure/server/handlers/pushBatchValidation.d.ts +3 -1
- package/dist/infrastructure/server/handlers/pushBatchValidation.js +56 -8
- package/dist/infrastructure/server/handlers/query.d.ts +1 -1
- package/dist/infrastructure/server/handlers/query.js +5 -4
- package/dist/infrastructure/server/http.js +2 -2
- package/dist/infrastructure/server/httpDashboardEndpoints.d.ts +1 -1
- package/dist/infrastructure/server/httpDashboardEndpoints.js +19 -6
- package/dist/infrastructure/server/httpEndpoints.js +18 -7
- package/dist/infrastructure/server/httpRouteQueues.js +11 -1
- package/dist/infrastructure/server/protocol/validation.d.ts +1 -0
- package/dist/infrastructure/server/protocol/validation.js +1 -0
- package/dist/infrastructure/server/protocol.d.ts +1 -1
- package/dist/infrastructure/server/protocol.js +1 -1
- package/dist/infrastructure/server/shutdownCoordinator.d.ts +24 -0
- package/dist/infrastructure/server/shutdownCoordinator.js +106 -0
- package/dist/infrastructure/server/sseHandler.js +8 -3
- package/dist/infrastructure/server/storageAdapter.d.ts +29 -0
- package/dist/infrastructure/server/storageAdapter.js +61 -0
- package/dist/infrastructure/server/storageManager.d.ts +12 -0
- package/dist/infrastructure/server/storageManager.js +102 -0
- package/dist/infrastructure/server/tcp.js +2 -3
- package/dist/infrastructure/server/ws/snapshots.d.ts +1 -1
- package/dist/infrastructure/server/ws/snapshots.js +19 -4
- package/dist/infrastructure/server/wsHandler.js +10 -5
- package/dist/main.js +1 -1
- package/dist/mcp/backend/embedded/services.js +2 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +2 -2
- package/dist/shared/storageHealth.d.ts +9 -0
- package/dist/shared/storageHealth.js +12 -0
- package/package.json +75 -65
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jobId } from '../../../../domain/types/job';
|
|
2
2
|
import * as response from '../../../../domain/types/response';
|
|
3
|
+
import { sanitizeServerError } from '../../errors';
|
|
3
4
|
export async function handleGetFailedChildrenValues(command, context, requestId) {
|
|
4
5
|
try {
|
|
5
6
|
const values = await context.queueManager.getFailedChildrenValues(jobId(command.id));
|
|
6
7
|
return { ok: true, values, reqId: requestId };
|
|
7
8
|
}
|
|
8
|
-
catch {
|
|
9
|
-
return
|
|
9
|
+
catch (error) {
|
|
10
|
+
return response.error(sanitizeServerError(error), requestId);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
export async function handleGetIgnoredChildrenFailures(command, context, requestId) {
|
|
@@ -14,8 +15,8 @@ export async function handleGetIgnoredChildrenFailures(command, context, request
|
|
|
14
15
|
const values = await context.queueManager.getIgnoredChildrenFailures(jobId(command.id));
|
|
15
16
|
return { ok: true, values, reqId: requestId };
|
|
16
17
|
}
|
|
17
|
-
catch {
|
|
18
|
-
return
|
|
18
|
+
catch (error) {
|
|
19
|
+
return response.error(sanitizeServerError(error), requestId);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
export async function handleRemoveChildDependency(command, context, requestId) {
|
|
@@ -24,7 +25,7 @@ export async function handleRemoveChildDependency(command, context, requestId) {
|
|
|
24
25
|
return { ok: true, removed, reqId: requestId };
|
|
25
26
|
}
|
|
26
27
|
catch (error) {
|
|
27
|
-
return response.error(
|
|
28
|
+
return response.error(sanitizeServerError(error), requestId);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
export async function handleRemoveUnprocessedChildren(command, context, requestId) {
|
|
@@ -33,6 +34,6 @@ export async function handleRemoveUnprocessedChildren(command, context, requestI
|
|
|
33
34
|
return response.ok(undefined, requestId);
|
|
34
35
|
}
|
|
35
36
|
catch (error) {
|
|
36
|
-
return response.error(
|
|
37
|
+
return response.error(sanitizeServerError(error), requestId);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jobId } from '../../../../domain/types/job';
|
|
2
2
|
import * as response from '../../../../domain/types/response';
|
|
3
3
|
import { validateNumericField } from '../../protocol';
|
|
4
|
+
import { sanitizeServerError } from '../../errors';
|
|
4
5
|
export async function handleUpdate(command, context, requestId) {
|
|
5
6
|
const success = await context.queueManager.updateJobData(jobId(command.id), command.data);
|
|
6
7
|
if (success)
|
|
@@ -35,7 +36,7 @@ export async function handleUpdateParent(command, context, requestId) {
|
|
|
35
36
|
return response.ok(undefined, requestId);
|
|
36
37
|
}
|
|
37
38
|
catch (error) {
|
|
38
|
-
return response.error(error
|
|
39
|
+
return response.error(sanitizeServerError(error), requestId);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
export async function handleMoveToDelayed(command, context, requestId) {
|
|
@@ -69,13 +70,22 @@ export async function handleWaitJob(command, context, requestId) {
|
|
|
69
70
|
return response.error(timeoutError, requestId);
|
|
70
71
|
const timeout = command.timeout ?? 30000;
|
|
71
72
|
const job = await context.queueManager.getJob(id);
|
|
72
|
-
if (!job)
|
|
73
|
-
|
|
73
|
+
if (!job) {
|
|
74
|
+
const completion = await context.queueManager.getCompletionAsync(id);
|
|
75
|
+
if (!completion.found)
|
|
76
|
+
return response.error('Job not found', requestId);
|
|
77
|
+
return {
|
|
78
|
+
ok: true,
|
|
79
|
+
completed: true,
|
|
80
|
+
result: completion.result,
|
|
81
|
+
reqId: requestId,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
74
84
|
if (job.completedAt) {
|
|
75
85
|
return {
|
|
76
86
|
ok: true,
|
|
77
87
|
completed: true,
|
|
78
|
-
result: context.queueManager.
|
|
88
|
+
result: await context.queueManager.getResultAsync(id),
|
|
79
89
|
reqId: requestId,
|
|
80
90
|
};
|
|
81
91
|
}
|
|
@@ -84,7 +94,7 @@ export async function handleWaitJob(command, context, requestId) {
|
|
|
84
94
|
return {
|
|
85
95
|
ok: true,
|
|
86
96
|
completed: true,
|
|
87
|
-
result: context.queueManager.
|
|
97
|
+
result: await context.queueManager.getResultAsync(id),
|
|
88
98
|
reqId: requestId,
|
|
89
99
|
};
|
|
90
100
|
}
|
|
@@ -121,7 +131,10 @@ export async function handleMoveToWait(command, context, requestId) {
|
|
|
121
131
|
const job = await context.queueManager.getJob(id);
|
|
122
132
|
if (!job)
|
|
123
133
|
return response.error('Job not found', requestId);
|
|
124
|
-
const
|
|
134
|
+
const manager = context.queueManager;
|
|
135
|
+
const count = manager.retryDlqDurable
|
|
136
|
+
? await manager.retryDlqDurable(job.queue, id)
|
|
137
|
+
: manager.retryDlq(job.queue, id);
|
|
125
138
|
return count > 0
|
|
126
139
|
? response.ok(undefined, requestId)
|
|
127
140
|
: response.error('Failed job not in DLQ', requestId);
|
|
@@ -3,40 +3,40 @@ import type { Response } from '../../../../domain/types/response';
|
|
|
3
3
|
import type { HandlerContext } from '../../types';
|
|
4
4
|
export declare function handleIsPaused(command: Extract<Command, {
|
|
5
5
|
cmd: 'IsPaused';
|
|
6
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
6
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
7
7
|
export declare function handleObliterate(command: Extract<Command, {
|
|
8
8
|
cmd: 'Obliterate';
|
|
9
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
9
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
10
10
|
export declare function handleListQueues(_command: Extract<Command, {
|
|
11
11
|
cmd: 'ListQueues';
|
|
12
12
|
}>, context: HandlerContext, requestId?: string): Response;
|
|
13
13
|
export declare function handleClean(command: Extract<Command, {
|
|
14
14
|
cmd: 'Clean';
|
|
15
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
15
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
16
16
|
export declare function handleCount(command: Extract<Command, {
|
|
17
17
|
cmd: 'Count';
|
|
18
18
|
}>, context: HandlerContext, requestId?: string): Response;
|
|
19
19
|
export declare function handleRateLimit(command: Extract<Command, {
|
|
20
20
|
cmd: 'RateLimit';
|
|
21
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
21
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
22
22
|
export declare function handleRateLimitClear(command: Extract<Command, {
|
|
23
23
|
cmd: 'RateLimitClear';
|
|
24
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
24
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
25
25
|
export declare function handleSetConcurrency(command: Extract<Command, {
|
|
26
26
|
cmd: 'SetConcurrency';
|
|
27
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
27
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
28
28
|
export declare function handleClearConcurrency(command: Extract<Command, {
|
|
29
29
|
cmd: 'ClearConcurrency';
|
|
30
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
30
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
31
31
|
export declare function handleSetStallConfig(command: Extract<Command, {
|
|
32
32
|
cmd: 'SetStallConfig';
|
|
33
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
33
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
34
34
|
export declare function handleGetStallConfig(command: Extract<Command, {
|
|
35
35
|
cmd: 'GetStallConfig';
|
|
36
36
|
}>, context: HandlerContext, requestId?: string): Response;
|
|
37
37
|
export declare function handleSetDlqConfig(command: Extract<Command, {
|
|
38
38
|
cmd: 'SetDlqConfig';
|
|
39
|
-
}>, context: HandlerContext, requestId?: string): Response
|
|
39
|
+
}>, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
40
40
|
export declare function handleGetDlqConfig(command: Extract<Command, {
|
|
41
41
|
cmd: 'GetDlqConfig';
|
|
42
42
|
}>, context: HandlerContext, requestId?: string): Response;
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import * as response from '../../../../domain/types/response';
|
|
2
2
|
import { sanitizeConfigNumbers, toFiniteNumber } from './configNumbers';
|
|
3
3
|
export function handleIsPaused(command, context, requestId) {
|
|
4
|
+
const manager = context.queueManager;
|
|
5
|
+
if (manager.isPausedDurable) {
|
|
6
|
+
return manager.isPausedDurable(command.queue).then((paused) => ({
|
|
7
|
+
ok: true,
|
|
8
|
+
paused,
|
|
9
|
+
reqId: requestId,
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
4
12
|
return {
|
|
5
13
|
ok: true,
|
|
6
|
-
paused:
|
|
14
|
+
paused: manager.isPaused(command.queue),
|
|
7
15
|
reqId: requestId,
|
|
8
16
|
};
|
|
9
17
|
}
|
|
10
18
|
export function handleObliterate(command, context, requestId) {
|
|
11
|
-
context.queueManager
|
|
19
|
+
const manager = context.queueManager;
|
|
20
|
+
if (manager.obliterateDurable) {
|
|
21
|
+
return manager.obliterateDurable(command.queue).then(() => response.ok(undefined, requestId));
|
|
22
|
+
}
|
|
23
|
+
manager.obliterate(command.queue);
|
|
12
24
|
return response.ok(undefined, requestId);
|
|
13
25
|
}
|
|
14
26
|
export function handleListQueues(_command, context, requestId) {
|
|
@@ -19,15 +31,24 @@ export function handleListQueues(_command, context, requestId) {
|
|
|
19
31
|
};
|
|
20
32
|
}
|
|
21
33
|
export function handleClean(command, context, requestId) {
|
|
22
|
-
const
|
|
34
|
+
const manager = context.queueManager;
|
|
35
|
+
if (manager.cleanDurable) {
|
|
36
|
+
return manager
|
|
37
|
+
.cleanDurable(command.queue, command.grace, command.state, command.limit)
|
|
38
|
+
.then((ids) => cleanResponse(manager, command.queue, command.state, ids, requestId));
|
|
39
|
+
}
|
|
40
|
+
const ids = manager.clean(command.queue, command.grace, command.state, command.limit);
|
|
41
|
+
return cleanResponse(manager, command.queue, command.state, ids, requestId);
|
|
42
|
+
}
|
|
43
|
+
function cleanResponse(manager, queue, state, ids, requestId) {
|
|
23
44
|
if (ids.length > 0) {
|
|
24
|
-
|
|
25
|
-
queue
|
|
26
|
-
state
|
|
45
|
+
manager.emitDashboardEvent('queue:cleaned', {
|
|
46
|
+
queue,
|
|
47
|
+
state,
|
|
27
48
|
count: ids.length,
|
|
28
49
|
});
|
|
29
50
|
}
|
|
30
|
-
return { ok: true, count: ids.length, ids, reqId: requestId };
|
|
51
|
+
return { ok: true, count: ids.length, ids: [...ids], reqId: requestId };
|
|
31
52
|
}
|
|
32
53
|
export function handleCount(command, context, requestId) {
|
|
33
54
|
return { ok: true, count: context.queueManager.count(command.queue), reqId: requestId };
|
|
@@ -38,8 +59,19 @@ export function handleRateLimit(command, context, requestId) {
|
|
|
38
59
|
return response.error('limit must be a finite number', requestId);
|
|
39
60
|
const duration = toFiniteNumber(command.duration);
|
|
40
61
|
const ttl = toFiniteNumber(command.ttl);
|
|
41
|
-
context.queueManager
|
|
42
|
-
|
|
62
|
+
const manager = context.queueManager;
|
|
63
|
+
if (manager.setRateLimitDurable) {
|
|
64
|
+
return manager.setRateLimitDurable(command.queue, limit, duration ?? 1000, ttl).then(() => {
|
|
65
|
+
manager.emitDashboardEvent('ratelimit:set', {
|
|
66
|
+
queue: command.queue,
|
|
67
|
+
max: limit,
|
|
68
|
+
duration: duration ?? 1000,
|
|
69
|
+
});
|
|
70
|
+
return response.ok(undefined, requestId);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
manager.setRateLimit(command.queue, limit, duration, ttl);
|
|
74
|
+
manager.emitDashboardEvent('ratelimit:set', {
|
|
43
75
|
queue: command.queue,
|
|
44
76
|
max: limit,
|
|
45
77
|
...(duration !== undefined && { duration }),
|
|
@@ -48,24 +80,48 @@ export function handleRateLimit(command, context, requestId) {
|
|
|
48
80
|
return response.ok(undefined, requestId);
|
|
49
81
|
}
|
|
50
82
|
export function handleRateLimitClear(command, context, requestId) {
|
|
51
|
-
context.queueManager
|
|
52
|
-
|
|
83
|
+
const manager = context.queueManager;
|
|
84
|
+
if (manager.setRateLimitDurable) {
|
|
85
|
+
return manager.setRateLimitDurable(command.queue, null, null).then(() => {
|
|
86
|
+
manager.emitDashboardEvent('ratelimit:cleared', { queue: command.queue });
|
|
87
|
+
return response.ok(undefined, requestId);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
manager.clearRateLimit(command.queue);
|
|
91
|
+
manager.emitDashboardEvent('ratelimit:cleared', { queue: command.queue });
|
|
53
92
|
return response.ok(undefined, requestId);
|
|
54
93
|
}
|
|
55
94
|
export function handleSetConcurrency(command, context, requestId) {
|
|
56
95
|
const limit = toFiniteNumber(command.limit);
|
|
57
96
|
if (limit === undefined)
|
|
58
97
|
return response.error('limit must be a finite number', requestId);
|
|
59
|
-
context.queueManager
|
|
60
|
-
|
|
98
|
+
const manager = context.queueManager;
|
|
99
|
+
if (manager.setConcurrencyDurable) {
|
|
100
|
+
return manager.setConcurrencyDurable(command.queue, limit).then(() => {
|
|
101
|
+
manager.emitDashboardEvent('concurrency:set', {
|
|
102
|
+
queue: command.queue,
|
|
103
|
+
concurrency: limit,
|
|
104
|
+
});
|
|
105
|
+
return response.ok(undefined, requestId);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
manager.setConcurrency(command.queue, limit);
|
|
109
|
+
manager.emitDashboardEvent('concurrency:set', {
|
|
61
110
|
queue: command.queue,
|
|
62
111
|
concurrency: limit,
|
|
63
112
|
});
|
|
64
113
|
return response.ok(undefined, requestId);
|
|
65
114
|
}
|
|
66
115
|
export function handleClearConcurrency(command, context, requestId) {
|
|
67
|
-
context.queueManager
|
|
68
|
-
|
|
116
|
+
const manager = context.queueManager;
|
|
117
|
+
if (manager.setConcurrencyDurable) {
|
|
118
|
+
return manager.setConcurrencyDurable(command.queue, null).then(() => {
|
|
119
|
+
manager.emitDashboardEvent('concurrency:cleared', { queue: command.queue });
|
|
120
|
+
return response.ok(undefined, requestId);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
manager.clearConcurrency(command.queue);
|
|
124
|
+
manager.emitDashboardEvent('concurrency:cleared', { queue: command.queue });
|
|
69
125
|
return response.ok(undefined, requestId);
|
|
70
126
|
}
|
|
71
127
|
export function handleSetStallConfig(command, context, requestId) {
|
|
@@ -74,12 +130,16 @@ export function handleSetStallConfig(command, context, requestId) {
|
|
|
74
130
|
'maxStalls',
|
|
75
131
|
'gracePeriod',
|
|
76
132
|
]);
|
|
77
|
-
context.queueManager
|
|
78
|
-
|
|
79
|
-
queue: command.queue,
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
133
|
+
const manager = context.queueManager;
|
|
134
|
+
const complete = () => {
|
|
135
|
+
manager.emitDashboardEvent('config:stall-changed', { queue: command.queue, config });
|
|
136
|
+
return response.ok(undefined, requestId);
|
|
137
|
+
};
|
|
138
|
+
if (manager.setStallConfigDurable) {
|
|
139
|
+
return manager.setStallConfigDurable(command.queue, config).then(complete);
|
|
140
|
+
}
|
|
141
|
+
manager.setStallConfig(command.queue, config);
|
|
142
|
+
return complete();
|
|
83
143
|
}
|
|
84
144
|
export function handleGetStallConfig(command, context, requestId) {
|
|
85
145
|
return {
|
|
@@ -95,12 +155,16 @@ export function handleSetDlqConfig(command, context, requestId) {
|
|
|
95
155
|
'maxAge',
|
|
96
156
|
'maxEntries',
|
|
97
157
|
]);
|
|
98
|
-
context.queueManager
|
|
99
|
-
|
|
100
|
-
queue: command.queue,
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
158
|
+
const manager = context.queueManager;
|
|
159
|
+
const complete = () => {
|
|
160
|
+
manager.emitDashboardEvent('config:dlq-changed', { queue: command.queue, config });
|
|
161
|
+
return response.ok(undefined, requestId);
|
|
162
|
+
};
|
|
163
|
+
if (manager.setDlqConfigDurable) {
|
|
164
|
+
return manager.setDlqConfigDurable(command.queue, config).then(complete);
|
|
165
|
+
}
|
|
166
|
+
manager.setDlqConfig(command.queue, config);
|
|
167
|
+
return complete();
|
|
104
168
|
}
|
|
105
169
|
export function handleGetDlqConfig(command, context, requestId) {
|
|
106
170
|
return {
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
/** Core command handlers for push, pull, acknowledgement, and failure. */
|
|
2
1
|
import type { Command } from '../../../domain/types/command';
|
|
3
2
|
import type { Response } from '../../../domain/types/response';
|
|
4
3
|
import type { HandlerContext } from '../types';
|
|
5
|
-
/** Handle PUSH command */
|
|
6
4
|
export declare function handlePush(cmd: Extract<Command, {
|
|
7
5
|
cmd: 'PUSH';
|
|
8
6
|
}>, ctx: HandlerContext, reqId?: string): Promise<Response>;
|
|
9
|
-
/** Handle PUSHB (batch push) command */
|
|
10
7
|
export declare function handlePushBatch(cmd: Extract<Command, {
|
|
11
8
|
cmd: 'PUSHB';
|
|
12
9
|
}>, ctx: HandlerContext, reqId?: string): Promise<Response>;
|
|
13
|
-
/** Handle PULL command */
|
|
14
10
|
export declare function handlePull(cmd: Extract<Command, {
|
|
15
11
|
cmd: 'PULL';
|
|
16
12
|
}>, ctx: HandlerContext, reqId?: string): Promise<Response>;
|
|
17
|
-
/** Handle PULLB (batch pull) command - uses optimized single-lock batch pull */
|
|
18
13
|
export declare function handlePullBatch(cmd: Extract<Command, {
|
|
19
14
|
cmd: 'PULLB';
|
|
20
15
|
}>, ctx: HandlerContext, reqId?: string): Promise<Response>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/** Core command handlers for push, pull, acknowledgement, and failure. */
|
|
2
1
|
import * as resp from '../../../domain/types/response';
|
|
2
|
+
import { validateGroupPullOptions } from '../../../domain/types/group';
|
|
3
3
|
import { jobId, normalizeLegacyJobPayload } from '../../../domain/types/job';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { tcpLog } from '../../../shared/logger';
|
|
5
|
+
import { sanitizeServerError, serverErrorDiagnostics } from '../errors';
|
|
6
|
+
import { validateQueueName, validateGroupId, validateJobData, validateJobOptions, validateNumericField, } from '../protocol';
|
|
7
|
+
import { validatePushBatchJobs, validatePushDependencies } from './pushBatchValidation';
|
|
7
8
|
export async function handlePush(cmd, ctx, reqId) {
|
|
8
9
|
const queueError = validateQueueName(cmd.queue);
|
|
9
10
|
if (queueError)
|
|
@@ -11,7 +12,9 @@ export async function handlePush(cmd, ctx, reqId) {
|
|
|
11
12
|
const dataError = validateJobData(cmd.data);
|
|
12
13
|
if (dataError)
|
|
13
14
|
return resp.error(dataError, reqId);
|
|
14
|
-
|
|
15
|
+
const groupError = validateGroupId(cmd.groupId);
|
|
16
|
+
if (groupError)
|
|
17
|
+
return resp.error(groupError, reqId);
|
|
15
18
|
const optionsError = validateJobOptions({
|
|
16
19
|
priority: cmd.priority,
|
|
17
20
|
delay: cmd.delay,
|
|
@@ -22,23 +25,10 @@ export async function handlePush(cmd, ctx, reqId) {
|
|
|
22
25
|
});
|
|
23
26
|
if (optionsError)
|
|
24
27
|
return resp.error(optionsError, reqId);
|
|
25
|
-
// Validate dependsOn references exist
|
|
26
|
-
if (cmd.dependsOn && cmd.dependsOn.length > 0) {
|
|
27
|
-
for (const depId of cmd.dependsOn) {
|
|
28
|
-
const depJobId = jobId(depId);
|
|
29
|
-
const exists = ctx.queueManager.getJobIndex().has(depJobId) ||
|
|
30
|
-
ctx.queueManager.getCompletedJobs().has(depJobId) ||
|
|
31
|
-
// A removeOnComplete parent that completed is recorded only here (its row
|
|
32
|
-
// is deleted and it leaves jobIndex/completedJobs). The readiness path and
|
|
33
|
-
// dependency processor already honor depCompletions; the gate must too, or
|
|
34
|
-
// a late dependent is wrongly rejected with "Dependency job not found".
|
|
35
|
-
ctx.queueManager.getDepCompletions().has(depJobId);
|
|
36
|
-
if (!exists) {
|
|
37
|
-
return resp.error(`Dependency job not found: ${depId}`, reqId);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
28
|
try {
|
|
29
|
+
const dependencyError = await validatePushDependencies(cmd.dependsOn, ctx);
|
|
30
|
+
if (dependencyError)
|
|
31
|
+
return resp.error(dependencyError, reqId);
|
|
42
32
|
const payload = normalizeLegacyJobPayload(cmd);
|
|
43
33
|
const job = await ctx.queueManager.push(cmd.queue, {
|
|
44
34
|
name: payload.name,
|
|
@@ -77,69 +67,69 @@ export async function handlePush(cmd, ctx, reqId) {
|
|
|
77
67
|
return resp.ok(job.id, reqId);
|
|
78
68
|
}
|
|
79
69
|
catch (err) {
|
|
80
|
-
|
|
81
|
-
return resp.error(message, reqId);
|
|
70
|
+
return resp.error(sanitizeServerError(err), reqId);
|
|
82
71
|
}
|
|
83
72
|
}
|
|
84
|
-
/** Handle PUSHB (batch push) command */
|
|
85
73
|
export async function handlePushBatch(cmd, ctx, reqId) {
|
|
86
74
|
const queueError = validateQueueName(cmd.queue);
|
|
87
75
|
if (queueError)
|
|
88
76
|
return resp.error(queueError, reqId);
|
|
89
77
|
// PUSH parity: per-job data/option bounds + dependsOn existence gate
|
|
90
78
|
// (extended to earlier same-batch custom ids for intra-batch chains).
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
try {
|
|
80
|
+
const jobsError = await validatePushBatchJobs(cmd.jobs, ctx);
|
|
81
|
+
if (jobsError)
|
|
82
|
+
return resp.error(jobsError, reqId);
|
|
83
|
+
const inputs = cmd.jobs.map((job) => {
|
|
84
|
+
const payload = normalizeLegacyJobPayload(job);
|
|
85
|
+
return { ...job, name: payload.name, data: payload.data };
|
|
86
|
+
});
|
|
87
|
+
const ids = await ctx.queueManager.pushBatch(cmd.queue, inputs);
|
|
88
|
+
return resp.batch(ids, reqId);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return resp.error(sanitizeServerError(error), reqId);
|
|
92
|
+
}
|
|
100
93
|
}
|
|
101
|
-
/** Handle PULL command */
|
|
102
94
|
export async function handlePull(cmd, ctx, reqId) {
|
|
103
95
|
const queueError = validateQueueName(cmd.queue);
|
|
104
96
|
if (queueError)
|
|
105
97
|
return resp.error(queueError, reqId);
|
|
106
|
-
// Validate timeout
|
|
107
98
|
const timeoutError = validateNumericField(cmd.timeout, 'timeout', { min: 0, max: 60000 });
|
|
108
99
|
if (timeoutError)
|
|
109
100
|
return resp.error(timeoutError, reqId);
|
|
110
|
-
|
|
101
|
+
const groupError = validateGroupPullOptions(cmd.group);
|
|
102
|
+
if (groupError)
|
|
103
|
+
return resp.error(groupError, reqId);
|
|
111
104
|
if (cmd.owner) {
|
|
112
|
-
const { job, token } = await ctx.queueManager.pullWithLock(cmd.queue, cmd.owner, cmd.timeout, cmd.lockTtl, ctx.signal);
|
|
113
|
-
// Register job with client for connection-based release
|
|
105
|
+
const { job, token } = await ctx.queueManager.pullWithLock(cmd.queue, cmd.owner, cmd.timeout, cmd.lockTtl, ctx.signal, cmd.group);
|
|
114
106
|
if (job && ctx.clientId) {
|
|
115
107
|
ctx.queueManager.registerClientJob(ctx.clientId, job.id);
|
|
116
108
|
}
|
|
117
109
|
return resp.pulledJob(job, token, reqId);
|
|
118
110
|
}
|
|
119
111
|
// Standard pull (no lock, but still track for client release unless detached)
|
|
120
|
-
const job = await ctx.queueManager.pull(cmd.queue, cmd.timeout, ctx.signal);
|
|
112
|
+
const job = await ctx.queueManager.pull(cmd.queue, cmd.timeout, ctx.signal, cmd.group);
|
|
121
113
|
if (job && ctx.clientId && !cmd.detach) {
|
|
122
114
|
ctx.queueManager.registerClientJob(ctx.clientId, job.id);
|
|
123
115
|
}
|
|
124
116
|
return resp.nullableJob(job, reqId);
|
|
125
117
|
}
|
|
126
|
-
/** Handle PULLB (batch pull) command - uses optimized single-lock batch pull */
|
|
127
118
|
export async function handlePullBatch(cmd, ctx, reqId) {
|
|
128
119
|
const queueError = validateQueueName(cmd.queue);
|
|
129
120
|
if (queueError)
|
|
130
121
|
return resp.error(queueError, reqId);
|
|
131
|
-
// Validate count
|
|
132
122
|
const countError = validateNumericField(cmd.count, 'count', { min: 1, max: 1000 });
|
|
133
123
|
if (countError)
|
|
134
124
|
return resp.error(countError, reqId);
|
|
135
|
-
// Validate timeout (same bound as PULL)
|
|
136
125
|
const timeoutError = validateNumericField(cmd.timeout, 'timeout', { min: 0, max: 60000 });
|
|
137
126
|
if (timeoutError)
|
|
138
127
|
return resp.error(timeoutError, reqId);
|
|
139
|
-
|
|
128
|
+
const groupError = validateGroupPullOptions(cmd.group);
|
|
129
|
+
if (groupError)
|
|
130
|
+
return resp.error(groupError, reqId);
|
|
140
131
|
if (cmd.owner) {
|
|
141
|
-
const { jobs, tokens } = await ctx.queueManager.pullBatchWithLock(cmd.queue, cmd.count, cmd.owner, cmd.timeout ?? 0, cmd.lockTtl, ctx.signal);
|
|
142
|
-
// Register all jobs with client for connection-based release
|
|
132
|
+
const { jobs, tokens } = await ctx.queueManager.pullBatchWithLock(cmd.queue, cmd.count, cmd.owner, cmd.timeout ?? 0, cmd.lockTtl, ctx.signal, cmd.group);
|
|
143
133
|
if (ctx.clientId) {
|
|
144
134
|
for (const job of jobs) {
|
|
145
135
|
ctx.queueManager.registerClientJob(ctx.clientId, job.id);
|
|
@@ -149,7 +139,7 @@ export async function handlePullBatch(cmd, ctx, reqId) {
|
|
|
149
139
|
}
|
|
150
140
|
// Standard pull (no locks, but still track for client release) — the
|
|
151
141
|
// non-owner branch honors cmd.timeout exactly like the owner branch and PULL.
|
|
152
|
-
const jobs = await ctx.queueManager.pullBatch(cmd.queue, cmd.count, cmd.timeout ?? 0, ctx.signal);
|
|
142
|
+
const jobs = await ctx.queueManager.pullBatch(cmd.queue, cmd.count, cmd.timeout ?? 0, ctx.signal, cmd.group);
|
|
153
143
|
if (ctx.clientId) {
|
|
154
144
|
for (const job of jobs) {
|
|
155
145
|
ctx.queueManager.registerClientJob(ctx.clientId, job.id);
|
|
@@ -169,7 +159,7 @@ export async function handleAck(cmd, ctx, reqId) {
|
|
|
169
159
|
return outcome ? resp.data(outcome, reqId) : resp.ok(undefined, reqId);
|
|
170
160
|
}
|
|
171
161
|
catch (err) {
|
|
172
|
-
return resp.error(
|
|
162
|
+
return resp.error(sanitizeServerError(err), reqId);
|
|
173
163
|
}
|
|
174
164
|
}
|
|
175
165
|
/** Handle ACKB (batch ack) command - supports optional results and tokens */
|
|
@@ -210,7 +200,15 @@ export async function handleAckBatch(cmd, ctx, reqId) {
|
|
|
210
200
|
return outcome ? resp.data(outcome, reqId) : resp.ok(undefined, reqId);
|
|
211
201
|
}
|
|
212
202
|
catch (err) {
|
|
213
|
-
|
|
203
|
+
const message = sanitizeServerError(err);
|
|
204
|
+
if (message === 'Internal server error') {
|
|
205
|
+
tcpLog.error('ACKB failed', {
|
|
206
|
+
...serverErrorDiagnostics(err),
|
|
207
|
+
batchSize: ids.length,
|
|
208
|
+
...(reqId && { reqId }),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return resp.error(message, reqId);
|
|
214
212
|
}
|
|
215
213
|
}
|
|
216
214
|
/** Handle FAIL command */
|
|
@@ -229,6 +227,6 @@ export async function handleFail(cmd, ctx, reqId) {
|
|
|
229
227
|
return outcome ? resp.data(outcome, reqId) : resp.ok(undefined, reqId);
|
|
230
228
|
}
|
|
231
229
|
catch (err) {
|
|
232
|
-
return resp.error(
|
|
230
|
+
return resp.error(sanitizeServerError(err), reqId);
|
|
233
231
|
}
|
|
234
232
|
}
|
|
@@ -8,16 +8,16 @@ import type { HandlerContext } from '../types';
|
|
|
8
8
|
/** Handle Cron command - add cron job */
|
|
9
9
|
export declare function handleCron(cmd: Extract<Command, {
|
|
10
10
|
cmd: 'Cron';
|
|
11
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
11
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
12
12
|
/** Handle CronGet command - get single cron job by name */
|
|
13
13
|
export declare function handleCronGet(cmd: Extract<Command, {
|
|
14
14
|
cmd: 'CronGet';
|
|
15
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
15
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
16
16
|
/** Handle CronDelete command - delete cron job */
|
|
17
17
|
export declare function handleCronDelete(cmd: Extract<Command, {
|
|
18
18
|
cmd: 'CronDelete';
|
|
19
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
19
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
20
20
|
/** Handle CronList command - list cron jobs */
|
|
21
21
|
export declare function handleCronList(_cmd: Extract<Command, {
|
|
22
22
|
cmd: 'CronList';
|
|
23
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
23
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|