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,16 +1,21 @@
|
|
|
1
1
|
import { jobId } from '../../../domain/types/job';
|
|
2
2
|
import { mapCloudCommandJob } from './jobMapper';
|
|
3
|
+
function pageInteger(value, fallback) {
|
|
4
|
+
if (value === undefined || !Number.isFinite(value))
|
|
5
|
+
return fallback;
|
|
6
|
+
return Math.min(Number.MAX_SAFE_INTEGER, Math.max(0, Math.floor(value)));
|
|
7
|
+
}
|
|
3
8
|
export const JOB_COMMANDS = {
|
|
4
|
-
'job:cancel': async (
|
|
5
|
-
const ok = await
|
|
9
|
+
'job:cancel': async (adapter, command) => {
|
|
10
|
+
const ok = await adapter.cancel(jobId(command.jobId ?? ''));
|
|
6
11
|
return { cancelled: ok };
|
|
7
12
|
},
|
|
8
|
-
'job:promote': async (
|
|
9
|
-
const ok = await
|
|
13
|
+
'job:promote': async (adapter, command) => {
|
|
14
|
+
const ok = await adapter.promote(jobId(command.jobId ?? ''));
|
|
10
15
|
return { promoted: ok };
|
|
11
16
|
},
|
|
12
|
-
'job:push': async (
|
|
13
|
-
const job = await
|
|
17
|
+
'job:push': async (adapter, command) => {
|
|
18
|
+
const job = await adapter.push(command.queue ?? '', {
|
|
14
19
|
name: command.name ?? 'default',
|
|
15
20
|
data: command.data ?? {},
|
|
16
21
|
priority: command.priority,
|
|
@@ -18,80 +23,83 @@ export const JOB_COMMANDS = {
|
|
|
18
23
|
});
|
|
19
24
|
return { jobId: String(job.id), queue: command.queue };
|
|
20
25
|
},
|
|
21
|
-
'job:priority': async (
|
|
22
|
-
const ok = await
|
|
26
|
+
'job:priority': async (adapter, command) => {
|
|
27
|
+
const ok = await adapter.changePriority(jobId(command.jobId ?? ''), command.priority ?? 0);
|
|
23
28
|
return { changed: ok };
|
|
24
29
|
},
|
|
25
|
-
'job:discard': async (
|
|
26
|
-
const ok = await
|
|
30
|
+
'job:discard': async (adapter, command) => {
|
|
31
|
+
const ok = await adapter.discard(jobId(command.jobId ?? ''));
|
|
27
32
|
return { discarded: ok };
|
|
28
33
|
},
|
|
29
|
-
'job:delay': async (
|
|
30
|
-
await
|
|
34
|
+
'job:delay': async (adapter, command) => {
|
|
35
|
+
await adapter.changeDelay(jobId(command.jobId ?? ''), command.delay ?? 0);
|
|
31
36
|
return { delayed: true };
|
|
32
37
|
},
|
|
33
|
-
'job:updateData': async (
|
|
34
|
-
const ok = await
|
|
38
|
+
'job:updateData': async (adapter, command) => {
|
|
39
|
+
const ok = await adapter.updateData(jobId(command.jobId ?? ''), command.data);
|
|
35
40
|
return { updated: ok };
|
|
36
41
|
},
|
|
37
|
-
'job:clearLogs': (
|
|
38
|
-
|
|
42
|
+
'job:clearLogs': async (adapter, command) => {
|
|
43
|
+
await adapter.clearLogs(jobId(command.jobId ?? ''), command.keepLogs);
|
|
39
44
|
return { cleared: true };
|
|
40
45
|
},
|
|
41
|
-
'job:retry': (
|
|
46
|
+
'job:retry': async (adapter, command) => {
|
|
42
47
|
if (command.queue) {
|
|
43
|
-
const count =
|
|
48
|
+
const count = await adapter.retryDlq(command.queue, command.jobId ? jobId(command.jobId) : undefined);
|
|
44
49
|
return { retried: count };
|
|
45
50
|
}
|
|
46
51
|
return { retried: 0 };
|
|
47
52
|
},
|
|
48
|
-
'job:logs': (
|
|
49
|
-
logs:
|
|
53
|
+
'job:logs': async (adapter, command) => ({
|
|
54
|
+
logs: await adapter.getLogs(jobId(command.jobId ?? '')),
|
|
50
55
|
}),
|
|
51
|
-
'job:result': (
|
|
52
|
-
result:
|
|
56
|
+
'job:result': async (adapter, command) => ({
|
|
57
|
+
result: await adapter.getResult(jobId(command.jobId ?? '')),
|
|
53
58
|
}),
|
|
54
|
-
'job:list': (
|
|
55
|
-
const limit = command.limit
|
|
56
|
-
const offset = command.offset
|
|
59
|
+
'job:list': async (adapter, command) => {
|
|
60
|
+
const limit = pageInteger(command.limit, 50);
|
|
61
|
+
const offset = pageInteger(command.offset, 0);
|
|
62
|
+
const end = Math.min(Number.MAX_SAFE_INTEGER, offset + limit);
|
|
57
63
|
const states = command.state
|
|
58
64
|
? command.state.split(',')
|
|
59
65
|
: ['waiting', 'active', 'delayed', 'completed', 'failed'];
|
|
60
|
-
const jobs =
|
|
66
|
+
const jobs = await adapter.listJobs(command.queue ?? '', {
|
|
61
67
|
state: states,
|
|
62
68
|
start: offset,
|
|
63
|
-
end
|
|
69
|
+
end,
|
|
64
70
|
});
|
|
71
|
+
const source = await adapter.readSnapshotSource();
|
|
72
|
+
const counts = source.queues.find(({ name }) => name === (command.queue ?? ''))?.counts;
|
|
65
73
|
return {
|
|
66
74
|
jobs: jobs.map(mapCloudCommandJob),
|
|
67
|
-
total:
|
|
75
|
+
total: (counts?.waiting ?? 0) + (counts?.prioritized ?? 0) + (counts?.delayed ?? 0),
|
|
68
76
|
offset,
|
|
69
77
|
limit,
|
|
70
78
|
};
|
|
71
79
|
},
|
|
72
|
-
'job:get': async (
|
|
80
|
+
'job:get': async (adapter, command) => {
|
|
73
81
|
const id = jobId(command.jobId ?? '');
|
|
74
|
-
const job = await
|
|
82
|
+
const job = await adapter.getJob(id);
|
|
75
83
|
if (!job)
|
|
76
84
|
return { job: null };
|
|
77
85
|
return {
|
|
78
86
|
job: {
|
|
79
87
|
...mapCloudCommandJob(job),
|
|
80
|
-
logs:
|
|
81
|
-
result:
|
|
88
|
+
logs: await adapter.getLogs(id),
|
|
89
|
+
result: await adapter.getResult(id),
|
|
82
90
|
},
|
|
83
91
|
};
|
|
84
92
|
},
|
|
85
|
-
'job:listAll': (
|
|
93
|
+
'job:listAll': async (adapter, command) => {
|
|
86
94
|
const limit = command.limit ?? 50;
|
|
87
95
|
const offset = command.offset ?? 0;
|
|
88
96
|
const states = command.state
|
|
89
97
|
? command.state.split(',')
|
|
90
98
|
: ['waiting', 'active', 'delayed', 'completed', 'failed'];
|
|
91
99
|
const allJobs = [];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
const source = await adapter.readSnapshotSource();
|
|
101
|
+
for (const { job, state } of source.jobs) {
|
|
102
|
+
if (states.includes(state))
|
|
95
103
|
allJobs.push(mapCloudCommandJob(job));
|
|
96
104
|
}
|
|
97
105
|
allJobs.sort((a, b) => b.timestamp - a.timestamp);
|
|
@@ -102,10 +110,10 @@ export const JOB_COMMANDS = {
|
|
|
102
110
|
limit,
|
|
103
111
|
};
|
|
104
112
|
},
|
|
105
|
-
'dlq:retry': (
|
|
106
|
-
retried:
|
|
113
|
+
'dlq:retry': async (adapter, command) => ({
|
|
114
|
+
retried: await adapter.retryDlq(command.queue ?? '', command.jobId ? jobId(command.jobId) : undefined),
|
|
107
115
|
}),
|
|
108
|
-
'dlq:purge': (
|
|
109
|
-
purged:
|
|
116
|
+
'dlq:purge': async (adapter, command) => ({
|
|
117
|
+
purged: await adapter.purgeDlq(command.queue ?? ''),
|
|
110
118
|
}),
|
|
111
119
|
};
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
+
import { DEFAULT_DLQ_CONFIG } from '../../../domain/types/dlq';
|
|
2
|
+
import { DEFAULT_STALL_CONFIG } from '../../../domain/types/stall';
|
|
1
3
|
import { mapCloudCommandJob } from './jobMapper';
|
|
2
4
|
export const QUEUE_COMMANDS = {
|
|
3
|
-
'queue:pause': (
|
|
4
|
-
|
|
5
|
+
'queue:pause': async (adapter, command) => {
|
|
6
|
+
await adapter.pause(command.queue ?? '', true);
|
|
5
7
|
return { queue: command.queue, paused: true };
|
|
6
8
|
},
|
|
7
|
-
'queue:resume': (
|
|
8
|
-
|
|
9
|
+
'queue:resume': async (adapter, command) => {
|
|
10
|
+
await adapter.pause(command.queue ?? '', false);
|
|
9
11
|
return { queue: command.queue, paused: false };
|
|
10
12
|
},
|
|
11
|
-
'queue:drain': (
|
|
12
|
-
const count =
|
|
13
|
+
'queue:drain': async (adapter, command) => {
|
|
14
|
+
const count = await adapter.drain(command.queue ?? '');
|
|
13
15
|
return { queue: command.queue, drained: count };
|
|
14
16
|
},
|
|
15
|
-
'queue:clean': (
|
|
16
|
-
const ids =
|
|
17
|
+
'queue:clean': async (adapter, command) => {
|
|
18
|
+
const ids = await adapter.clean(command.queue ?? '', command.graceMs ?? 0, command.state, command.limit);
|
|
17
19
|
return { queue: command.queue, cleaned: ids.length, ids };
|
|
18
20
|
},
|
|
19
|
-
'queue:obliterate': (
|
|
20
|
-
|
|
21
|
+
'queue:obliterate': async (adapter, command) => {
|
|
22
|
+
await adapter.obliterate(command.queue ?? '');
|
|
21
23
|
return { queue: command.queue, obliterated: true };
|
|
22
24
|
},
|
|
23
|
-
'queue:promoteAll': async (
|
|
25
|
+
'queue:promoteAll': async (adapter, command) => {
|
|
24
26
|
const limit = command.limit ?? 1000;
|
|
25
|
-
const
|
|
26
|
-
state: ['delayed'],
|
|
27
|
-
start: 0,
|
|
28
|
-
end: limit - 1,
|
|
29
|
-
});
|
|
30
|
-
let promoted = 0;
|
|
31
|
-
for (const job of jobs) {
|
|
32
|
-
try {
|
|
33
|
-
await queueManager.promote(job.id);
|
|
34
|
-
promoted++;
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// Skip jobs that can no longer be promoted.
|
|
38
|
-
}
|
|
39
|
-
}
|
|
27
|
+
const promoted = await adapter.promoteAll(command.queue ?? '', limit);
|
|
40
28
|
return { queue: command.queue, promoted };
|
|
41
29
|
},
|
|
42
|
-
'queue:retryCompleted': (
|
|
43
|
-
const count =
|
|
30
|
+
'queue:retryCompleted': async (adapter, command) => {
|
|
31
|
+
const count = await adapter.retryCompleted(command.queue ?? '');
|
|
44
32
|
return { queue: command.queue, retried: count };
|
|
45
33
|
},
|
|
46
|
-
'queue:rateLimit': (
|
|
47
|
-
|
|
34
|
+
'queue:rateLimit': async (adapter, command) => {
|
|
35
|
+
await adapter.setRateLimit(command.queue ?? '', command.max ?? 100);
|
|
48
36
|
return { queue: command.queue, rateLimit: command.max ?? 100 };
|
|
49
37
|
},
|
|
50
|
-
'queue:clearRateLimit': (
|
|
51
|
-
|
|
38
|
+
'queue:clearRateLimit': async (adapter, command) => {
|
|
39
|
+
await adapter.setRateLimit(command.queue ?? '', null);
|
|
52
40
|
return { queue: command.queue, rateLimit: null };
|
|
53
41
|
},
|
|
54
|
-
'queue:concurrency': (
|
|
55
|
-
|
|
42
|
+
'queue:concurrency': async (adapter, command) => {
|
|
43
|
+
await adapter.setConcurrency(command.queue ?? '', command.concurrency ?? 10);
|
|
56
44
|
return { queue: command.queue, concurrency: command.concurrency ?? 10 };
|
|
57
45
|
},
|
|
58
|
-
'queue:clearConcurrency': (
|
|
59
|
-
|
|
46
|
+
'queue:clearConcurrency': async (adapter, command) => {
|
|
47
|
+
await adapter.setConcurrency(command.queue ?? '', null);
|
|
60
48
|
return { queue: command.queue, concurrency: null };
|
|
61
49
|
},
|
|
62
|
-
'queue:stallConfig': (
|
|
63
|
-
|
|
50
|
+
'queue:stallConfig': async (adapter, command) => {
|
|
51
|
+
await adapter.setStallConfig(command.queue ?? '', command.config ?? {});
|
|
64
52
|
return { queue: command.queue, stallConfig: command.config };
|
|
65
53
|
},
|
|
66
|
-
'queue:dlqConfig': (
|
|
67
|
-
|
|
54
|
+
'queue:dlqConfig': async (adapter, command) => {
|
|
55
|
+
await adapter.setDlqConfig(command.queue ?? '', command.config ?? {});
|
|
68
56
|
return { queue: command.queue, dlqConfig: command.config };
|
|
69
57
|
},
|
|
70
|
-
'queue:detail': (
|
|
58
|
+
'queue:detail': async (adapter, command) => {
|
|
71
59
|
const queue = command.queue ?? '';
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
const source = await adapter.readSnapshotSource([queue]);
|
|
61
|
+
const view = source.queues.find(({ name }) => name === queue);
|
|
62
|
+
const counts = view?.counts ?? {
|
|
63
|
+
waiting: 0,
|
|
64
|
+
prioritized: 0,
|
|
65
|
+
delayed: 0,
|
|
66
|
+
active: 0,
|
|
67
|
+
completed: 0,
|
|
68
|
+
failed: 0,
|
|
69
|
+
'waiting-children': 0,
|
|
70
|
+
totalCompleted: 0,
|
|
71
|
+
totalFailed: 0,
|
|
72
|
+
};
|
|
73
|
+
const dlqEntries = source.dlqEntries.filter((entry) => entry.job.queue === queue).slice(0, 50);
|
|
74
|
+
const jobs = await adapter.listJobs(queue, {
|
|
78
75
|
state: ['waiting', 'active', 'delayed', 'completed', 'failed'],
|
|
79
76
|
start: 0,
|
|
80
|
-
end:
|
|
77
|
+
end: 50,
|
|
81
78
|
});
|
|
82
79
|
return {
|
|
83
80
|
queue,
|
|
84
|
-
paused,
|
|
81
|
+
paused: view?.paused ?? false,
|
|
85
82
|
counts,
|
|
86
83
|
stallConfig: {
|
|
87
|
-
enabled: stallConfig.enabled,
|
|
88
|
-
stallInterval: stallConfig.stallInterval,
|
|
89
|
-
maxStalls: stallConfig.maxStalls,
|
|
84
|
+
enabled: view?.stallConfig.enabled ?? DEFAULT_STALL_CONFIG.enabled,
|
|
85
|
+
stallInterval: view?.stallConfig.stallInterval ?? DEFAULT_STALL_CONFIG.stallInterval,
|
|
86
|
+
maxStalls: view?.stallConfig.maxStalls ?? DEFAULT_STALL_CONFIG.maxStalls,
|
|
87
|
+
},
|
|
88
|
+
dlqConfig: {
|
|
89
|
+
maxRetries: view?.dlqConfig.maxAutoRetries ?? DEFAULT_DLQ_CONFIG.maxAutoRetries,
|
|
90
|
+
maxAge: view?.dlqConfig.maxAge ?? DEFAULT_DLQ_CONFIG.maxAge ?? 0,
|
|
90
91
|
},
|
|
91
|
-
dlqConfig: { maxRetries: dlqConfig.maxAutoRetries, maxAge: dlqConfig.maxAge ?? 0 },
|
|
92
92
|
dlqEntries: dlqEntries.map((entry) => ({
|
|
93
93
|
jobId: String(entry.job.id),
|
|
94
94
|
reason: entry.reason,
|
|
@@ -99,28 +99,14 @@ export const QUEUE_COMMANDS = {
|
|
|
99
99
|
jobs: jobs.map(mapCloudCommandJob),
|
|
100
100
|
};
|
|
101
101
|
},
|
|
102
|
-
'queue:list': (
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
name,
|
|
111
|
-
waiting: counts.waiting,
|
|
112
|
-
prioritized: counts.prioritized,
|
|
113
|
-
delayed: counts.delayed,
|
|
114
|
-
active: counts.active,
|
|
115
|
-
completed: counts.completed,
|
|
116
|
-
failed: counts.failed,
|
|
117
|
-
'waiting-children': counts['waiting-children'],
|
|
118
|
-
paused: queueManager.isPaused(name),
|
|
119
|
-
totalCompleted: counts.totalCompleted,
|
|
120
|
-
totalFailed: counts.totalFailed,
|
|
121
|
-
};
|
|
122
|
-
});
|
|
102
|
+
'queue:list': async (adapter) => {
|
|
103
|
+
const source = await adapter.readSnapshotSource();
|
|
104
|
+
const queues = source.queues.map(({ name, counts, paused }) => ({
|
|
105
|
+
name,
|
|
106
|
+
...counts,
|
|
107
|
+
paused,
|
|
108
|
+
}));
|
|
123
109
|
return { queues };
|
|
124
110
|
},
|
|
125
|
-
'stats:refresh': (
|
|
111
|
+
'stats:refresh': async (adapter) => (await adapter.readSnapshotSource()).stats,
|
|
126
112
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { QueueManager } from '../../../application/queueManager';
|
|
2
|
+
import type { CronJobInput } from '../../../domain/types/cron';
|
|
3
|
+
import type { JobId } from '../../../domain/types/job';
|
|
4
|
+
import type { CloudQueueAdapter, CloudSnapshotSource } from './types';
|
|
5
|
+
/** SQLite/local Cloud strategy; delegates to the existing synchronous semantics. */
|
|
6
|
+
export declare class LocalCloudQueueAdapter implements CloudQueueAdapter {
|
|
7
|
+
readonly manager: QueueManager;
|
|
8
|
+
constructor(manager: QueueManager);
|
|
9
|
+
pause(queue: string, paused: boolean): Promise<void>;
|
|
10
|
+
drain(queue: string): Promise<number>;
|
|
11
|
+
clean(queue: string, graceMs: number, state?: string, limit?: number): Promise<JobId[]>;
|
|
12
|
+
obliterate(queue: string): Promise<void>;
|
|
13
|
+
promoteAll(queue: string, limit: number): Promise<number>;
|
|
14
|
+
retryCompleted(queue: string): Promise<number>;
|
|
15
|
+
setRateLimit(queue: string, limit: number | null): Promise<void>;
|
|
16
|
+
setConcurrency(queue: string, limit: number | null): Promise<void>;
|
|
17
|
+
setStallConfig(queue: string, patch: Record<string, unknown>): Promise<void>;
|
|
18
|
+
setDlqConfig(queue: string, patch: Record<string, unknown>): Promise<void>;
|
|
19
|
+
listJobs(queue: string, options?: {
|
|
20
|
+
state?: string | string[];
|
|
21
|
+
start?: number;
|
|
22
|
+
end?: number;
|
|
23
|
+
asc?: boolean;
|
|
24
|
+
}): Promise<import("../../../domain/types").Job[]>;
|
|
25
|
+
getJob(id: JobId): Promise<import("../../../domain/types").Job | null>;
|
|
26
|
+
getLogs(id: JobId): Promise<import("../../../domain/types/worker").JobLogEntry[]>;
|
|
27
|
+
getResult(id: JobId): Promise<unknown>;
|
|
28
|
+
clearLogs(id: JobId, keepLogs?: number): Promise<void>;
|
|
29
|
+
retryDlq(queue: string, id?: JobId): Promise<number>;
|
|
30
|
+
purgeDlq(queue: string): Promise<number>;
|
|
31
|
+
push(queue: string, input: Parameters<QueueManager['push']>[1]): Promise<import("../../../domain/types").Job>;
|
|
32
|
+
cancel(id: JobId): Promise<boolean>;
|
|
33
|
+
promote(id: JobId): Promise<boolean>;
|
|
34
|
+
changePriority(id: JobId, priority: number): Promise<boolean>;
|
|
35
|
+
discard(id: JobId): Promise<boolean>;
|
|
36
|
+
changeDelay(id: JobId, delay: number): Promise<boolean>;
|
|
37
|
+
updateData(id: JobId, data: unknown): Promise<boolean>;
|
|
38
|
+
addCron(input: CronJobInput): Promise<import("../../../domain/types").CronJob>;
|
|
39
|
+
removeCron(name: string): Promise<boolean>;
|
|
40
|
+
readSnapshotSource(requestedQueues?: readonly string[]): Promise<CloudSnapshotSource>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const SNAPSHOT_STATES = [
|
|
2
|
+
'waiting',
|
|
3
|
+
'active',
|
|
4
|
+
'delayed',
|
|
5
|
+
'failed',
|
|
6
|
+
'completed',
|
|
7
|
+
'prioritized',
|
|
8
|
+
'paused',
|
|
9
|
+
'waiting-children',
|
|
10
|
+
];
|
|
11
|
+
/** SQLite/local Cloud strategy; delegates to the existing synchronous semantics. */
|
|
12
|
+
export class LocalCloudQueueAdapter {
|
|
13
|
+
manager;
|
|
14
|
+
constructor(manager) {
|
|
15
|
+
this.manager = manager;
|
|
16
|
+
}
|
|
17
|
+
pause(queue, paused) {
|
|
18
|
+
if (paused)
|
|
19
|
+
this.manager.pause(queue);
|
|
20
|
+
else
|
|
21
|
+
this.manager.resume(queue);
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
}
|
|
24
|
+
drain(queue) {
|
|
25
|
+
return Promise.resolve(this.manager.drain(queue));
|
|
26
|
+
}
|
|
27
|
+
clean(queue, graceMs, state, limit) {
|
|
28
|
+
return Promise.resolve(this.manager.clean(queue, graceMs, state, limit));
|
|
29
|
+
}
|
|
30
|
+
obliterate(queue) {
|
|
31
|
+
this.manager.obliterate(queue);
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
}
|
|
34
|
+
async promoteAll(queue, limit) {
|
|
35
|
+
const jobs = this.manager.getJobs(queue, { state: ['delayed'], start: 0, end: limit });
|
|
36
|
+
let promoted = 0;
|
|
37
|
+
for (const job of jobs) {
|
|
38
|
+
try {
|
|
39
|
+
if (await this.manager.promote(job.id))
|
|
40
|
+
promoted++;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// The job may have moved since the command selected it.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return promoted;
|
|
47
|
+
}
|
|
48
|
+
retryCompleted(queue) {
|
|
49
|
+
return Promise.resolve(this.manager.retryCompleted(queue));
|
|
50
|
+
}
|
|
51
|
+
setRateLimit(queue, limit) {
|
|
52
|
+
if (limit === null)
|
|
53
|
+
this.manager.clearRateLimit(queue);
|
|
54
|
+
else
|
|
55
|
+
this.manager.setRateLimit(queue, limit);
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
setConcurrency(queue, limit) {
|
|
59
|
+
if (limit === null)
|
|
60
|
+
this.manager.clearConcurrency(queue);
|
|
61
|
+
else
|
|
62
|
+
this.manager.setConcurrency(queue, limit);
|
|
63
|
+
return Promise.resolve();
|
|
64
|
+
}
|
|
65
|
+
setStallConfig(queue, patch) {
|
|
66
|
+
this.manager.setStallConfig(queue, patch);
|
|
67
|
+
return Promise.resolve();
|
|
68
|
+
}
|
|
69
|
+
setDlqConfig(queue, patch) {
|
|
70
|
+
this.manager.setDlqConfig(queue, patch);
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
}
|
|
73
|
+
listJobs(queue, options = {}) {
|
|
74
|
+
return Promise.resolve(this.manager.getJobs(queue, options));
|
|
75
|
+
}
|
|
76
|
+
async getJob(id) {
|
|
77
|
+
return await this.manager.getJob(id);
|
|
78
|
+
}
|
|
79
|
+
getLogs(id) {
|
|
80
|
+
return Promise.resolve(this.manager.getLogs(id));
|
|
81
|
+
}
|
|
82
|
+
getResult(id) {
|
|
83
|
+
return Promise.resolve(this.manager.getResult(id) ?? null);
|
|
84
|
+
}
|
|
85
|
+
clearLogs(id, keepLogs) {
|
|
86
|
+
this.manager.clearLogs(id, keepLogs);
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
}
|
|
89
|
+
retryDlq(queue, id) {
|
|
90
|
+
return Promise.resolve(this.manager.retryDlq(queue, id));
|
|
91
|
+
}
|
|
92
|
+
purgeDlq(queue) {
|
|
93
|
+
return Promise.resolve(this.manager.purgeDlq(queue));
|
|
94
|
+
}
|
|
95
|
+
async push(queue, input) {
|
|
96
|
+
return await this.manager.push(queue, input);
|
|
97
|
+
}
|
|
98
|
+
async cancel(id) {
|
|
99
|
+
return await this.manager.cancel(id);
|
|
100
|
+
}
|
|
101
|
+
async promote(id) {
|
|
102
|
+
return await this.manager.promote(id);
|
|
103
|
+
}
|
|
104
|
+
async changePriority(id, priority) {
|
|
105
|
+
return await this.manager.changePriority(id, priority);
|
|
106
|
+
}
|
|
107
|
+
async discard(id) {
|
|
108
|
+
return await this.manager.discard(id);
|
|
109
|
+
}
|
|
110
|
+
async changeDelay(id, delay) {
|
|
111
|
+
return await this.manager.changeDelay(id, delay);
|
|
112
|
+
}
|
|
113
|
+
async updateData(id, data) {
|
|
114
|
+
return await this.manager.updateJobData(id, data);
|
|
115
|
+
}
|
|
116
|
+
addCron(input) {
|
|
117
|
+
return Promise.resolve(this.manager.addCron(input));
|
|
118
|
+
}
|
|
119
|
+
removeCron(name) {
|
|
120
|
+
return Promise.resolve(this.manager.removeCron(name));
|
|
121
|
+
}
|
|
122
|
+
readSnapshotSource(requestedQueues = []) {
|
|
123
|
+
const queueNames = new Set([...this.manager.listQueues(), ...requestedQueues]);
|
|
124
|
+
const counts = this.manager.getQueueJobCountsBatch(queueNames);
|
|
125
|
+
const queues = [];
|
|
126
|
+
const jobs = [];
|
|
127
|
+
const dlqEntries = [];
|
|
128
|
+
for (const name of queueNames) {
|
|
129
|
+
try {
|
|
130
|
+
const queueCounts = counts.get(name);
|
|
131
|
+
if (!queueCounts)
|
|
132
|
+
continue;
|
|
133
|
+
const limits = this.manager.getQueueLimits(name);
|
|
134
|
+
queues.push({
|
|
135
|
+
name,
|
|
136
|
+
counts: queueCounts,
|
|
137
|
+
paused: this.manager.isPaused(name),
|
|
138
|
+
rateLimit: limits.rateLimit,
|
|
139
|
+
concurrencyLimit: limits.concurrencyLimit,
|
|
140
|
+
stallConfig: this.manager.getStallConfig(name),
|
|
141
|
+
dlqConfig: this.manager.getDlqConfig(name),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Preserve the local collector's per-queue best-effort behavior.
|
|
146
|
+
}
|
|
147
|
+
for (const state of SNAPSHOT_STATES) {
|
|
148
|
+
try {
|
|
149
|
+
for (const job of this.manager.getJobs(name, { state: [state], start: 0, end: 1000 })) {
|
|
150
|
+
jobs.push({ job, state });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Preserve the local collector's per-state best-effort behavior.
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
dlqEntries.push(...this.manager.getDlqEntries(name));
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// Preserve the local collector's per-queue best-effort behavior.
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const jobResults = new Map();
|
|
165
|
+
for (const [id, result] of this.manager.getAllJobResults()) {
|
|
166
|
+
jobResults.set(String(id), result);
|
|
167
|
+
}
|
|
168
|
+
const jobLogs = new Map();
|
|
169
|
+
for (const [id, logs] of this.manager.getAllJobLogs())
|
|
170
|
+
jobLogs.set(String(id), logs);
|
|
171
|
+
return Promise.resolve({
|
|
172
|
+
stats: this.manager.getStats(),
|
|
173
|
+
queues,
|
|
174
|
+
jobs,
|
|
175
|
+
dlqEntries,
|
|
176
|
+
workers: this.manager.workerManager.list(),
|
|
177
|
+
workerStats: this.manager.workerManager.getStats(),
|
|
178
|
+
crons: this.manager.listCrons(),
|
|
179
|
+
jobResults,
|
|
180
|
+
jobLogs,
|
|
181
|
+
activeLocks: [...this.manager.getAllJobLocks().values()].map((lock) => ({
|
|
182
|
+
...lock,
|
|
183
|
+
jobId: String(lock.jobId),
|
|
184
|
+
})),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PostgresQueueManager } from '../../../application/postgresQueueManager';
|
|
2
|
+
import type { CronJobInput } from '../../../domain/types/cron';
|
|
3
|
+
import type { JobId } from '../../../domain/types/job';
|
|
4
|
+
import type { CloudQueueAdapter, CloudSnapshotSource } from './types';
|
|
5
|
+
/** PostgreSQL Cloud strategy; every shared surface goes through durable APIs. */
|
|
6
|
+
export declare class PostgresCloudQueueAdapter implements CloudQueueAdapter {
|
|
7
|
+
readonly manager: PostgresQueueManager;
|
|
8
|
+
constructor(manager: PostgresQueueManager);
|
|
9
|
+
pause: (queue: string, paused: boolean) => Promise<void>;
|
|
10
|
+
drain: (queue: string) => Promise<number>;
|
|
11
|
+
clean: (queue: string, graceMs: number, state?: string, limit?: number) => Promise<JobId[]>;
|
|
12
|
+
obliterate: (queue: string) => Promise<void>;
|
|
13
|
+
promoteAll: (queue: string, limit: number) => Promise<number>;
|
|
14
|
+
retryCompleted: (queue: string) => Promise<number>;
|
|
15
|
+
setRateLimit: (queue: string, limit: number | null) => Promise<void>;
|
|
16
|
+
setConcurrency: (queue: string, limit: number | null) => Promise<void>;
|
|
17
|
+
setStallConfig: (queue: string, patch: Record<string, unknown>) => Promise<void>;
|
|
18
|
+
setDlqConfig: (queue: string, patch: Record<string, unknown>) => Promise<void>;
|
|
19
|
+
listJobs: (queue: string, options?: {
|
|
20
|
+
state?: string | string[];
|
|
21
|
+
start?: number;
|
|
22
|
+
end?: number;
|
|
23
|
+
asc?: boolean;
|
|
24
|
+
}) => Promise<import("../../../domain/types").Job[]>;
|
|
25
|
+
getJob: (id: JobId) => Promise<import("../../../domain/types").Job | null>;
|
|
26
|
+
getLogs: (id: JobId) => Promise<import("../../../domain/types/worker").JobLogEntry[]>;
|
|
27
|
+
getResult: (id: JobId) => Promise<unknown>;
|
|
28
|
+
clearLogs: (id: JobId, keepLogs?: number) => Promise<void>;
|
|
29
|
+
retryDlq: (queue: string, id?: JobId) => Promise<number>;
|
|
30
|
+
purgeDlq: (queue: string) => Promise<number>;
|
|
31
|
+
push: (queue: string, input: Parameters<PostgresQueueManager["push"]>[1]) => Promise<import("../../../domain/types").Job>;
|
|
32
|
+
cancel: (id: JobId) => Promise<boolean>;
|
|
33
|
+
promote: (id: JobId) => Promise<boolean>;
|
|
34
|
+
changePriority: (id: JobId, priority: number) => Promise<boolean>;
|
|
35
|
+
discard: (id: JobId) => Promise<boolean>;
|
|
36
|
+
changeDelay: (id: JobId, delay: number) => Promise<boolean>;
|
|
37
|
+
updateData: (id: JobId, data: unknown) => Promise<boolean>;
|
|
38
|
+
addCron: (input: CronJobInput) => Promise<import("../../../domain/types").CronJob>;
|
|
39
|
+
removeCron: (name: string) => Promise<boolean>;
|
|
40
|
+
readSnapshotSource(requestedQueues?: readonly string[]): Promise<CloudSnapshotSource>;
|
|
41
|
+
private toSnapshotSource;
|
|
42
|
+
}
|