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
|
@@ -4,12 +4,26 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as resp from '../../../domain/types/response';
|
|
6
6
|
import { normalizeLegacyJobPayload } from '../../../domain/types/job';
|
|
7
|
+
import { sanitizeServerError } from '../errors';
|
|
8
|
+
function cronData(cron) {
|
|
9
|
+
return {
|
|
10
|
+
name: cron.name,
|
|
11
|
+
jobName: cron.jobName,
|
|
12
|
+
queue: cron.queue,
|
|
13
|
+
schedule: cron.schedule,
|
|
14
|
+
repeatEvery: cron.repeatEvery,
|
|
15
|
+
nextRun: cron.nextRun,
|
|
16
|
+
executions: cron.executions,
|
|
17
|
+
maxLimit: cron.maxLimit,
|
|
18
|
+
timezone: cron.timezone,
|
|
19
|
+
priority: cron.priority,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
7
22
|
/** Handle Cron command - add cron job */
|
|
8
23
|
export function handleCron(cmd, ctx, reqId) {
|
|
9
24
|
try {
|
|
10
25
|
const payload = normalizeLegacyJobPayload({ name: cmd.jobName, data: cmd.data });
|
|
11
|
-
const
|
|
12
|
-
const cron = ctx.queueManager.addCron({
|
|
26
|
+
const input = {
|
|
13
27
|
name: cmd.name,
|
|
14
28
|
jobName: payload.name,
|
|
15
29
|
queue: cmd.queue,
|
|
@@ -26,80 +40,67 @@ export function handleCron(cmd, ctx, reqId) {
|
|
|
26
40
|
skipIfNoWorker: cmd.skipIfNoWorker,
|
|
27
41
|
preventOverlap: cmd.preventOverlap,
|
|
28
42
|
jobOptions: cmd.jobOptions,
|
|
29
|
-
}
|
|
30
|
-
ctx.queueManager
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
pattern: cron.schedule ?? undefined,
|
|
34
|
-
every: cron.repeatEvery ?? undefined,
|
|
35
|
-
nextRun: cron.nextRun,
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
ok: true,
|
|
39
|
-
cron: {
|
|
43
|
+
};
|
|
44
|
+
const manager = ctx.queueManager;
|
|
45
|
+
const complete = (cron, existed) => {
|
|
46
|
+
manager.emitDashboardEvent(existed ? 'cron:updated' : 'cron:created', {
|
|
40
47
|
name: cron.name,
|
|
41
|
-
jobName: cron.jobName,
|
|
42
48
|
queue: cron.queue,
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
pattern: cron.schedule ?? undefined,
|
|
50
|
+
every: cron.repeatEvery ?? undefined,
|
|
45
51
|
nextRun: cron.nextRun,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
timezone: cron.timezone,
|
|
49
|
-
priority: cron.priority,
|
|
50
|
-
},
|
|
51
|
-
reqId,
|
|
52
|
+
});
|
|
53
|
+
return { ok: true, cron: cronData(cron), reqId };
|
|
52
54
|
};
|
|
55
|
+
if (manager.addCronDurable && manager.getCronDurable) {
|
|
56
|
+
const addCronDurable = manager.addCronDurable.bind(manager);
|
|
57
|
+
const getCronDurable = manager.getCronDurable.bind(manager);
|
|
58
|
+
return (async () => {
|
|
59
|
+
const existed = (await getCronDurable(cmd.name)) !== undefined;
|
|
60
|
+
return complete(await addCronDurable(input), existed);
|
|
61
|
+
})();
|
|
62
|
+
}
|
|
63
|
+
const existing = manager.getCron(cmd.name);
|
|
64
|
+
return complete(manager.addCron(input), existing !== undefined);
|
|
53
65
|
}
|
|
54
66
|
catch (err) {
|
|
55
|
-
return resp.error(err
|
|
67
|
+
return resp.error(sanitizeServerError(err), reqId);
|
|
56
68
|
}
|
|
57
69
|
}
|
|
58
70
|
/** Handle CronGet command - get single cron job by name */
|
|
59
71
|
export function handleCronGet(cmd, ctx, reqId) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
ok: true,
|
|
66
|
-
cron: {
|
|
67
|
-
name: cron.name,
|
|
68
|
-
jobName: cron.jobName,
|
|
69
|
-
queue: cron.queue,
|
|
70
|
-
schedule: cron.schedule,
|
|
71
|
-
repeatEvery: cron.repeatEvery,
|
|
72
|
-
nextRun: cron.nextRun,
|
|
73
|
-
executions: cron.executions,
|
|
74
|
-
maxLimit: cron.maxLimit,
|
|
75
|
-
timezone: cron.timezone,
|
|
76
|
-
},
|
|
77
|
-
reqId,
|
|
72
|
+
const manager = ctx.queueManager;
|
|
73
|
+
const complete = (cron) => {
|
|
74
|
+
if (!cron) {
|
|
75
|
+
return resp.error('Cron job not found', reqId);
|
|
76
|
+
}
|
|
77
|
+
return { ok: true, cron: cronData(cron), reqId };
|
|
78
78
|
};
|
|
79
|
+
return manager.getCronDurable
|
|
80
|
+
? manager.getCronDurable(cmd.name).then(complete)
|
|
81
|
+
: complete(manager.getCron(cmd.name));
|
|
79
82
|
}
|
|
80
83
|
/** Handle CronDelete command - delete cron job */
|
|
81
84
|
export function handleCronDelete(cmd, ctx, reqId) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
const manager = ctx.queueManager;
|
|
86
|
+
const complete = (removed) => {
|
|
87
|
+
if (removed)
|
|
88
|
+
manager.emitDashboardEvent('cron:deleted', { name: cmd.name });
|
|
89
|
+
return removed ? resp.ok(undefined, reqId) : resp.error('Cron job not found', reqId);
|
|
90
|
+
};
|
|
91
|
+
return manager.removeCronDurable
|
|
92
|
+
? manager.removeCronDurable(cmd.name).then(complete)
|
|
93
|
+
: complete(manager.removeCron(cmd.name));
|
|
86
94
|
}
|
|
87
95
|
/** Handle CronList command - list cron jobs */
|
|
88
96
|
export function handleCronList(_cmd, ctx, reqId) {
|
|
89
|
-
const
|
|
90
|
-
|
|
97
|
+
const manager = ctx.queueManager;
|
|
98
|
+
const complete = (crons) => ({
|
|
91
99
|
ok: true,
|
|
92
|
-
crons: crons.map(
|
|
93
|
-
name: c.name,
|
|
94
|
-
jobName: c.jobName,
|
|
95
|
-
queue: c.queue,
|
|
96
|
-
schedule: c.schedule,
|
|
97
|
-
repeatEvery: c.repeatEvery,
|
|
98
|
-
nextRun: c.nextRun,
|
|
99
|
-
executions: c.executions,
|
|
100
|
-
maxLimit: c.maxLimit,
|
|
101
|
-
timezone: c.timezone,
|
|
102
|
-
})),
|
|
100
|
+
crons: crons.map(cronData),
|
|
103
101
|
reqId,
|
|
104
|
-
};
|
|
102
|
+
});
|
|
103
|
+
return manager.listCronsDurable
|
|
104
|
+
? manager.listCronsDurable().then(complete)
|
|
105
|
+
: complete(manager.listCrons());
|
|
105
106
|
}
|
|
@@ -9,7 +9,7 @@ import type { HandlerContext } from '../types';
|
|
|
9
9
|
/** Dashboard overview - single call for all dashboard data */
|
|
10
10
|
export declare function handleDashboardOverview(_cmd: Extract<Command, {
|
|
11
11
|
cmd: 'DashboardOverview';
|
|
12
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
12
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
13
13
|
/** Dashboard queues - all queues with per-queue stats */
|
|
14
14
|
export declare function handleDashboardQueues(_cmd: Extract<Command, {
|
|
15
15
|
cmd: 'DashboardQueues';
|
|
@@ -7,17 +7,30 @@ import * as resp from '../../../domain/types/response';
|
|
|
7
7
|
import { throughputTracker } from '../../../application/throughputTracker';
|
|
8
8
|
import { latencyTracker } from '../../../application/latencyTracker';
|
|
9
9
|
import { pausedView } from '../../../shared/pausedView';
|
|
10
|
+
import { clientStorageStatus } from '../../../shared/storageHealth';
|
|
11
|
+
const WORKER_TIMEOUT_MS = parseInt(Bun.env.WORKER_TIMEOUT_MS ?? '30000', 10);
|
|
10
12
|
/** Dashboard overview - single call for all dashboard data */
|
|
11
13
|
export function handleDashboardOverview(_cmd, ctx, reqId) {
|
|
12
|
-
const
|
|
14
|
+
const manager = ctx.queueManager;
|
|
15
|
+
if (manager.listWorkersDurable || manager.listCronsDurable) {
|
|
16
|
+
return Promise.all([
|
|
17
|
+
manager.listWorkersDurable
|
|
18
|
+
? manager.listWorkersDurable()
|
|
19
|
+
: Promise.resolve(manager.workerManager.list()),
|
|
20
|
+
manager.listCronsDurable ? manager.listCronsDurable() : Promise.resolve(manager.listCrons()),
|
|
21
|
+
]).then(([workers, crons]) => dashboardOverviewResponse(manager, workers, crons, reqId));
|
|
22
|
+
}
|
|
23
|
+
return dashboardOverviewResponse(manager, manager.workerManager.list(), manager.listCrons(), reqId);
|
|
24
|
+
}
|
|
25
|
+
function dashboardOverviewResponse(queueManager, workers, crons, reqId) {
|
|
26
|
+
const stats = queueManager.getStats();
|
|
13
27
|
const rates = throughputTracker.getRates();
|
|
14
28
|
const latencies = latencyTracker.getPercentiles();
|
|
15
29
|
const avgLatencies = latencyTracker.getAverages();
|
|
16
|
-
const memStats =
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const storage = ctx.queueManager.getStorageStatus();
|
|
30
|
+
const memStats = queueManager.getMemoryStats();
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
const activeWorkers = workers.filter((worker) => now - worker.lastSeen < WORKER_TIMEOUT_MS);
|
|
33
|
+
const storage = clientStorageStatus(queueManager.getStorageStatus());
|
|
21
34
|
const mem = process.memoryUsage();
|
|
22
35
|
return resp.data({
|
|
23
36
|
stats: {
|
|
@@ -44,8 +57,8 @@ export function handleDashboardOverview(_cmd, ctx, reqId) {
|
|
|
44
57
|
},
|
|
45
58
|
collections: memStats,
|
|
46
59
|
workers: {
|
|
47
|
-
total:
|
|
48
|
-
active:
|
|
60
|
+
total: workers.length,
|
|
61
|
+
active: activeWorkers.length,
|
|
49
62
|
list: workers.map((w) => ({
|
|
50
63
|
id: w.id,
|
|
51
64
|
name: w.name,
|
|
@@ -15,12 +15,15 @@ export declare function handleGetDlqStats(cmd: Extract<Command, {
|
|
|
15
15
|
/** Handle RetryDlq command - retry DLQ jobs */
|
|
16
16
|
export declare function handleRetryDlq(cmd: Extract<Command, {
|
|
17
17
|
cmd: 'RetryDlq';
|
|
18
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
18
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
19
19
|
/** Handle PurgeDlq command - clear DLQ */
|
|
20
20
|
export declare function handlePurgeDlq(cmd: Extract<Command, {
|
|
21
21
|
cmd: 'PurgeDlq';
|
|
22
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
22
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
23
|
+
export declare function handleRemoveDlqJob(cmd: Extract<Command, {
|
|
24
|
+
cmd: 'RemoveDlqJob';
|
|
25
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
23
26
|
/** Handle RetryCompleted command - retry completed jobs */
|
|
24
27
|
export declare function handleRetryCompleted(cmd: Extract<Command, {
|
|
25
28
|
cmd: 'RetryCompleted';
|
|
26
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
29
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
@@ -21,32 +21,58 @@ export function handleGetDlqStats(cmd, ctx, reqId) {
|
|
|
21
21
|
/** Handle RetryDlq command - retry DLQ jobs */
|
|
22
22
|
export function handleRetryDlq(cmd, ctx, reqId) {
|
|
23
23
|
const jid = cmd.jobId ? jobId(cmd.jobId) : undefined;
|
|
24
|
+
const manager = ctx.queueManager;
|
|
25
|
+
if (manager.retryDlqDurable) {
|
|
26
|
+
return manager
|
|
27
|
+
.retryDlqDurable(cmd.queue, jid, cmd.count, cmd.filter)
|
|
28
|
+
.then((count) => retryDlqResponse(manager, cmd.queue, jid, count, reqId));
|
|
29
|
+
}
|
|
24
30
|
// #111-class: honour the caller's `count` cap instead of retrying the whole DLQ.
|
|
25
31
|
const count = cmd.filter
|
|
26
32
|
? ctx.queueManager.retryDlqByFilter(cmd.queue, cmd.filter)
|
|
27
33
|
: ctx.queueManager.retryDlq(cmd.queue, jid, cmd.count);
|
|
34
|
+
return retryDlqResponse(manager, cmd.queue, jid, count, reqId);
|
|
35
|
+
}
|
|
36
|
+
function retryDlqResponse(manager, queue, jid, count, reqId) {
|
|
28
37
|
if (count > 0) {
|
|
29
38
|
const event = jid ? 'dlq:retried' : 'dlq:retry-all';
|
|
30
|
-
const data = { queue
|
|
39
|
+
const data = { queue, count };
|
|
31
40
|
if (jid)
|
|
32
41
|
data.jobId = String(jid);
|
|
33
|
-
|
|
42
|
+
manager.emitDashboardEvent(event, data);
|
|
34
43
|
}
|
|
35
44
|
return { ok: true, count, reqId };
|
|
36
45
|
}
|
|
37
46
|
/** Handle PurgeDlq command - clear DLQ */
|
|
38
47
|
export function handlePurgeDlq(cmd, ctx, reqId) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
const manager = ctx.queueManager;
|
|
49
|
+
const complete = (count) => {
|
|
50
|
+
if (count > 0)
|
|
51
|
+
manager.emitDashboardEvent('dlq:purged', { queue: cmd.queue, count });
|
|
52
|
+
return { ok: true, count, reqId };
|
|
53
|
+
};
|
|
54
|
+
return manager.purgeDlqDurable
|
|
55
|
+
? manager.purgeDlqDurable(cmd.queue).then(complete)
|
|
56
|
+
: complete(manager.purgeDlq(cmd.queue));
|
|
57
|
+
}
|
|
58
|
+
export function handleRemoveDlqJob(cmd, ctx, reqId) {
|
|
59
|
+
const id = jobId(cmd.jobId);
|
|
60
|
+
const manager = ctx.queueManager;
|
|
61
|
+
return manager.removeDlqJobDurable
|
|
62
|
+
? manager.removeDlqJobDurable(cmd.queue, id).then((removed) => resp.data({ removed }, reqId))
|
|
63
|
+
: resp.data({ removed: manager.removeDlqJob(cmd.queue, id) }, reqId);
|
|
43
64
|
}
|
|
44
65
|
/** Handle RetryCompleted command - retry completed jobs */
|
|
45
66
|
export function handleRetryCompleted(cmd, ctx, reqId) {
|
|
46
67
|
const jid = cmd.id ? jobId(cmd.id) : undefined;
|
|
47
|
-
const
|
|
68
|
+
const options = {
|
|
48
69
|
limit: cmd.count,
|
|
49
70
|
timestamp: cmd.timestamp,
|
|
50
|
-
}
|
|
51
|
-
|
|
71
|
+
};
|
|
72
|
+
const manager = ctx.queueManager;
|
|
73
|
+
return manager.retryCompletedDurable
|
|
74
|
+
? manager
|
|
75
|
+
.retryCompletedDurable(cmd.queue, jid, options)
|
|
76
|
+
.then((count) => ({ ok: true, count, reqId }))
|
|
77
|
+
: { ok: true, count: manager.retryCompleted(cmd.queue, jid, options), reqId };
|
|
52
78
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as resp from '../../../domain/types/response';
|
|
2
2
|
import { normalizeLegacyJobPayload } from '../../../domain/types/job';
|
|
3
|
+
import { sanitizeServerError } from '../errors';
|
|
3
4
|
/** Commit the whole graph in one broker operation; validation happens pre-mutation. */
|
|
4
5
|
export async function handlePushFlow(cmd, ctx, reqId) {
|
|
5
6
|
try {
|
|
@@ -11,6 +12,6 @@ export async function handlePushFlow(cmd, ctx, reqId) {
|
|
|
11
12
|
return resp.data(result, reqId);
|
|
12
13
|
}
|
|
13
14
|
catch (error) {
|
|
14
|
-
return resp.error(
|
|
15
|
+
return resp.error(sanitizeServerError(error), reqId);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from '../../../domain/types/command';
|
|
2
|
+
import type { Response } from '../../../domain/types/response';
|
|
3
|
+
import type { HandlerContext } from '../types';
|
|
4
|
+
type GroupCommand = Extract<Command, {
|
|
5
|
+
groupId: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function handleGroupCommand(command: GroupCommand, context: HandlerContext, requestId?: string): Promise<Response>;
|
|
8
|
+
export declare function handleGroupsJobsCount(command: Extract<Command, {
|
|
9
|
+
cmd: 'GetGroupsJobsCount';
|
|
10
|
+
}>, context: HandlerContext, requestId?: string): Promise<Response>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { validatePositiveSafeInteger } from '../../../domain/types/group';
|
|
2
|
+
import * as resp from '../../../domain/types/response';
|
|
3
|
+
import { validateGroupId, validateQueueName } from '../protocol';
|
|
4
|
+
function validate(command) {
|
|
5
|
+
const queueError = validateQueueName(command.queue);
|
|
6
|
+
if (queueError)
|
|
7
|
+
return queueError;
|
|
8
|
+
return validateGroupId(command.groupId, true);
|
|
9
|
+
}
|
|
10
|
+
export async function handleGroupCommand(command, context, requestId) {
|
|
11
|
+
const error = validate(command);
|
|
12
|
+
if (error)
|
|
13
|
+
return resp.error(error, requestId);
|
|
14
|
+
const manager = context.queueManager;
|
|
15
|
+
switch (command.cmd) {
|
|
16
|
+
case 'GetGroupJobsCount':
|
|
17
|
+
return resp.data({ count: await manager.getGroupJobsCount(command.queue, command.groupId) }, requestId);
|
|
18
|
+
case 'GetGroupActiveCount':
|
|
19
|
+
return resp.data({ count: await manager.getGroupActiveCount(command.queue, command.groupId) }, requestId);
|
|
20
|
+
case 'SetGroupRateLimit': {
|
|
21
|
+
const maxError = validatePositiveSafeInteger(command.max, 'max');
|
|
22
|
+
const durationError = validatePositiveSafeInteger(command.duration, 'duration');
|
|
23
|
+
const numericError = maxError ?? durationError;
|
|
24
|
+
if (numericError)
|
|
25
|
+
return resp.error(numericError, requestId);
|
|
26
|
+
await manager.setGroupRateLimit(command.queue, command.groupId, command.max, command.duration);
|
|
27
|
+
return resp.ok(undefined, requestId);
|
|
28
|
+
}
|
|
29
|
+
case 'GetGroupRateLimit':
|
|
30
|
+
return resp.data({ limit: await manager.getGroupRateLimit(command.queue, command.groupId) }, requestId);
|
|
31
|
+
case 'RemoveGroupRateLimit':
|
|
32
|
+
return resp.data({ removed: await manager.removeGroupRateLimit(command.queue, command.groupId) }, requestId);
|
|
33
|
+
case 'GetGroupRateLimitTtl':
|
|
34
|
+
return resp.data({
|
|
35
|
+
ttl: await manager.getGroupRateLimitTtl(command.queue, command.groupId, command.maxJobs),
|
|
36
|
+
}, requestId);
|
|
37
|
+
case 'SetGroupConcurrency': {
|
|
38
|
+
const concurrencyError = validatePositiveSafeInteger(command.concurrency, 'concurrency');
|
|
39
|
+
if (concurrencyError)
|
|
40
|
+
return resp.error(concurrencyError, requestId);
|
|
41
|
+
await manager.setGroupConcurrency(command.queue, command.groupId, command.concurrency);
|
|
42
|
+
return resp.ok(undefined, requestId);
|
|
43
|
+
}
|
|
44
|
+
case 'GetGroupConcurrency':
|
|
45
|
+
return resp.data({ concurrency: await manager.getGroupConcurrency(command.queue, command.groupId) }, requestId);
|
|
46
|
+
case 'RemoveGroupConcurrency':
|
|
47
|
+
return resp.data({ removed: await manager.removeGroupConcurrency(command.queue, command.groupId) }, requestId);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export async function handleGroupsJobsCount(command, context, requestId) {
|
|
51
|
+
const queueError = validateQueueName(command.queue);
|
|
52
|
+
if (queueError)
|
|
53
|
+
return resp.error(queueError, requestId);
|
|
54
|
+
return resp.data({ count: await context.queueManager.getGroupsJobsCount(command.queue) }, requestId);
|
|
55
|
+
}
|
|
@@ -20,15 +20,15 @@ export declare function handleGetProgress(cmd: Extract<Command, {
|
|
|
20
20
|
/** Handle Pause command */
|
|
21
21
|
export declare function handlePause(cmd: Extract<Command, {
|
|
22
22
|
cmd: 'Pause';
|
|
23
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
23
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
24
24
|
/** Handle Resume command */
|
|
25
25
|
export declare function handleResume(cmd: Extract<Command, {
|
|
26
26
|
cmd: 'Resume';
|
|
27
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
27
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
28
28
|
/** Handle Drain command */
|
|
29
29
|
export declare function handleDrain(cmd: Extract<Command, {
|
|
30
30
|
cmd: 'Drain';
|
|
31
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
31
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
32
32
|
/** Handle Stats command */
|
|
33
33
|
export declare function handleStats(ctx: HandlerContext, reqId?: string): Response;
|
|
34
34
|
/** Handle StorageStatus command - get real disk/storage health */
|
|
@@ -40,8 +40,8 @@ export declare function handleMetrics(ctx: HandlerContext, reqId?: string): Resp
|
|
|
40
40
|
/** Handle the queue-scoped Metrics form. */
|
|
41
41
|
export declare function handleQueueMetrics(cmd: Extract<Command, {
|
|
42
42
|
cmd: 'Metrics';
|
|
43
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
43
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
44
44
|
/** Trim one queue's durable lifecycle-event journal. */
|
|
45
45
|
export declare function handleTrimEvents(cmd: Extract<Command, {
|
|
46
46
|
cmd: 'TrimEvents';
|
|
47
|
-
}>, ctx: HandlerContext, reqId?: string): Response
|
|
47
|
+
}>, ctx: HandlerContext, reqId?: string): Response | Promise<Response>;
|
|
@@ -7,6 +7,8 @@ import { jobId } from '../../../domain/types/job';
|
|
|
7
7
|
import { throughputTracker } from '../../../application/throughputTracker';
|
|
8
8
|
import { latencyTracker } from '../../../application/latencyTracker';
|
|
9
9
|
import { validateQueueName } from '../protocol/validation';
|
|
10
|
+
import { clientStorageStatus } from '../../../shared/storageHealth';
|
|
11
|
+
import { sanitizeServerError } from '../errors';
|
|
10
12
|
/** Handle Cancel command */
|
|
11
13
|
export async function handleCancel(cmd, ctx, reqId) {
|
|
12
14
|
const success = await ctx.queueManager.cancel(jobId(cmd.id));
|
|
@@ -48,18 +50,29 @@ export async function handleGetProgress(cmd, ctx, reqId) {
|
|
|
48
50
|
}
|
|
49
51
|
/** Handle Pause command */
|
|
50
52
|
export function handlePause(cmd, ctx, reqId) {
|
|
51
|
-
ctx.queueManager
|
|
53
|
+
const manager = ctx.queueManager;
|
|
54
|
+
if (manager.pauseDurable) {
|
|
55
|
+
return manager.pauseDurable(cmd.queue, true).then(() => resp.ok(undefined, reqId));
|
|
56
|
+
}
|
|
57
|
+
manager.pause(cmd.queue);
|
|
52
58
|
return resp.ok(undefined, reqId);
|
|
53
59
|
}
|
|
54
60
|
/** Handle Resume command */
|
|
55
61
|
export function handleResume(cmd, ctx, reqId) {
|
|
56
|
-
ctx.queueManager
|
|
62
|
+
const manager = ctx.queueManager;
|
|
63
|
+
if (manager.pauseDurable) {
|
|
64
|
+
return manager.pauseDurable(cmd.queue, false).then(() => resp.ok(undefined, reqId));
|
|
65
|
+
}
|
|
66
|
+
manager.resume(cmd.queue);
|
|
57
67
|
return resp.ok(undefined, reqId);
|
|
58
68
|
}
|
|
59
69
|
/** Handle Drain command */
|
|
60
70
|
export function handleDrain(cmd, ctx, reqId) {
|
|
61
|
-
const
|
|
62
|
-
|
|
71
|
+
const manager = ctx.queueManager;
|
|
72
|
+
if (manager.drainDurable) {
|
|
73
|
+
return manager.drainDurable(cmd.queue).then((count) => ({ ok: true, count, reqId }));
|
|
74
|
+
}
|
|
75
|
+
return { ok: true, count: manager.drain(cmd.queue), reqId };
|
|
63
76
|
}
|
|
64
77
|
/** Handle Stats command */
|
|
65
78
|
export function handleStats(ctx, reqId) {
|
|
@@ -79,7 +92,7 @@ export function handleStats(ctx, reqId) {
|
|
|
79
92
|
}
|
|
80
93
|
/** Handle StorageStatus command - get real disk/storage health */
|
|
81
94
|
export function handleStorageStatus(_cmd, ctx, reqId) {
|
|
82
|
-
const status = ctx.queueManager.getStorageStatus();
|
|
95
|
+
const status = clientStorageStatus(ctx.queueManager.getStorageStatus());
|
|
83
96
|
return resp.data({ diskFull: status.diskFull, error: status.error, since: status.since }, reqId);
|
|
84
97
|
}
|
|
85
98
|
/** Handle Metrics command */
|
|
@@ -108,11 +121,18 @@ export function handleQueueMetrics(cmd, ctx, reqId) {
|
|
|
108
121
|
if (cmd.type !== 'completed' && cmd.type !== 'failed') {
|
|
109
122
|
return resp.error("Metrics type must be 'completed' or 'failed'", reqId);
|
|
110
123
|
}
|
|
124
|
+
const manager = ctx.queueManager;
|
|
125
|
+
if (manager.getQueueMetricsDurable) {
|
|
126
|
+
return manager
|
|
127
|
+
.getQueueMetricsDurable(cmd.queue, cmd.type, cmd.start ?? 0, cmd.end ?? -1)
|
|
128
|
+
.then((metrics) => resp.data(metrics, reqId))
|
|
129
|
+
.catch((error) => resp.error(sanitizeServerError(error), reqId));
|
|
130
|
+
}
|
|
111
131
|
try {
|
|
112
|
-
return resp.data(
|
|
132
|
+
return resp.data(manager.getQueueMetrics(cmd.queue, cmd.type, cmd.start ?? 0, cmd.end ?? -1), reqId);
|
|
113
133
|
}
|
|
114
134
|
catch (error) {
|
|
115
|
-
return resp.error(
|
|
135
|
+
return resp.error(sanitizeServerError(error), reqId);
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
/** Trim one queue's durable lifecycle-event journal. */
|
|
@@ -120,10 +140,17 @@ export function handleTrimEvents(cmd, ctx, reqId) {
|
|
|
120
140
|
const queueError = validateQueueName(cmd.queue);
|
|
121
141
|
if (queueError)
|
|
122
142
|
return resp.error(queueError, reqId);
|
|
143
|
+
const manager = ctx.queueManager;
|
|
144
|
+
if (manager.trimQueueEventsDurable) {
|
|
145
|
+
return manager
|
|
146
|
+
.trimQueueEventsDurable(cmd.queue, cmd.maxLength)
|
|
147
|
+
.then((removed) => resp.data({ removed }, reqId))
|
|
148
|
+
.catch((error) => resp.error(sanitizeServerError(error), reqId));
|
|
149
|
+
}
|
|
123
150
|
try {
|
|
124
|
-
return resp.data({ removed:
|
|
151
|
+
return resp.data({ removed: manager.trimQueueEvents(cmd.queue, cmd.maxLength) }, reqId);
|
|
125
152
|
}
|
|
126
153
|
catch (error) {
|
|
127
|
-
return resp.error(
|
|
154
|
+
return resp.error(sanitizeServerError(error), reqId);
|
|
128
155
|
}
|
|
129
156
|
}
|
|
@@ -4,10 +4,10 @@ import type { Response } from '../../../../domain/types/response';
|
|
|
4
4
|
import type { HandlerContext } from '../../types';
|
|
5
5
|
export { PROTOCOL_VERSION };
|
|
6
6
|
export declare const SUPPORTED_CAPABILITIES: ProtocolCapability[];
|
|
7
|
-
export declare function handleAddLog(command: AddLogCommand, context: HandlerContext, requestId?: string): Response
|
|
8
|
-
export declare function handleGetLogs(command: GetLogsCommand, context: HandlerContext, requestId?: string): Response
|
|
9
|
-
export declare function handleHeartbeat(command: HeartbeatCommand, context: HandlerContext, requestId?: string): Response
|
|
10
|
-
export declare function handleJobHeartbeat(command: JobHeartbeatCommand, context: HandlerContext, requestId?: string): Response
|
|
11
|
-
export declare function handleJobHeartbeatBatch(command: JobHeartbeatBatchCommand, context: HandlerContext, requestId?: string): Response
|
|
7
|
+
export declare function handleAddLog(command: AddLogCommand, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
8
|
+
export declare function handleGetLogs(command: GetLogsCommand, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
9
|
+
export declare function handleHeartbeat(command: HeartbeatCommand, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
10
|
+
export declare function handleJobHeartbeat(command: JobHeartbeatCommand, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
11
|
+
export declare function handleJobHeartbeatBatch(command: JobHeartbeatBatchCommand, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
12
12
|
export declare function handlePing(_command: PingCommand, _context: HandlerContext, requestId?: string): Response;
|
|
13
13
|
export declare function handleHello(_command: HelloCommand, _context: HandlerContext, requestId?: string): Response;
|
|
@@ -5,18 +5,29 @@ import { VERSION } from '../../../../shared/version';
|
|
|
5
5
|
export { PROTOCOL_VERSION };
|
|
6
6
|
export const SUPPORTED_CAPABILITIES = [...PROTOCOL_CAPABILITIES];
|
|
7
7
|
export function handleAddLog(command, context, requestId) {
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const id = jobId(command.id);
|
|
9
|
+
const level = command.level ?? 'info';
|
|
10
|
+
const manager = context.queueManager;
|
|
11
|
+
const complete = (success) => success
|
|
10
12
|
? response.data({ added: true }, requestId)
|
|
11
13
|
: response.error('Job not found', requestId);
|
|
14
|
+
return manager.addLogDurable
|
|
15
|
+
? manager.addLogDurable(id, command.message, level).then(complete)
|
|
16
|
+
: complete(manager.addLog(id, command.message, level));
|
|
12
17
|
}
|
|
13
18
|
export function handleGetLogs(command, context, requestId) {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const id = jobId(command.id);
|
|
20
|
+
const manager = context.queueManager;
|
|
21
|
+
const complete = (all) => {
|
|
22
|
+
const total = all.length;
|
|
23
|
+
const logs = command.start === undefined && command.end === undefined
|
|
24
|
+
? all
|
|
25
|
+
: all.slice(command.start ?? 0, (command.end ?? total - 1) + 1);
|
|
26
|
+
return response.data({ logs, count: total }, requestId);
|
|
27
|
+
};
|
|
28
|
+
return manager.getLogsDurable
|
|
29
|
+
? manager.getLogsDurable(id).then(complete)
|
|
30
|
+
: complete(manager.getLogs(id));
|
|
20
31
|
}
|
|
21
32
|
export function handleHeartbeat(command, context, requestId) {
|
|
22
33
|
const stats = command.activeJobs !== undefined ||
|
|
@@ -28,15 +39,28 @@ export function handleHeartbeat(command, context, requestId) {
|
|
|
28
39
|
failed: command.failed,
|
|
29
40
|
}
|
|
30
41
|
: undefined;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const manager = context.queueManager;
|
|
43
|
+
const complete = (success) => {
|
|
44
|
+
if (success) {
|
|
45
|
+
manager.emitDashboardEvent('worker:heartbeat', { workerId: command.id });
|
|
46
|
+
return response.data({ ok: true }, requestId);
|
|
47
|
+
}
|
|
48
|
+
return response.error('Worker not found', requestId);
|
|
49
|
+
};
|
|
50
|
+
return manager.heartbeatWorkerDurable
|
|
51
|
+
? manager.heartbeatWorkerDurable(command.id, stats, context.clientId).then(complete)
|
|
52
|
+
: complete(manager.workerManager.heartbeat(command.id, stats));
|
|
37
53
|
}
|
|
38
54
|
export function handleJobHeartbeat(command, context, requestId) {
|
|
39
55
|
const id = jobId(command.id);
|
|
56
|
+
const manager = context.queueManager;
|
|
57
|
+
if (manager.heartbeatDurable) {
|
|
58
|
+
return manager
|
|
59
|
+
.heartbeatDurable(id, command.token, command.duration)
|
|
60
|
+
.then((success) => success
|
|
61
|
+
? response.data({ ok: true }, requestId)
|
|
62
|
+
: response.error('Job not found or not active (or invalid token)', requestId));
|
|
63
|
+
}
|
|
40
64
|
if (command.duration && command.token) {
|
|
41
65
|
const success = context.queueManager.renewJobLock(id, command.token, command.duration);
|
|
42
66
|
return success
|
|
@@ -50,8 +74,13 @@ export function handleJobHeartbeat(command, context, requestId) {
|
|
|
50
74
|
}
|
|
51
75
|
export function handleJobHeartbeatBatch(command, context, requestId) {
|
|
52
76
|
const ids = command.ids.map((id) => jobId(id));
|
|
53
|
-
const
|
|
54
|
-
|
|
77
|
+
const manager = context.queueManager;
|
|
78
|
+
if (manager.heartbeatBatchDurable) {
|
|
79
|
+
return manager
|
|
80
|
+
.heartbeatBatchDurable(ids, command.tokens)
|
|
81
|
+
.then((count) => response.data({ ok: true, count }, requestId));
|
|
82
|
+
}
|
|
83
|
+
return response.data({ ok: true, count: manager.jobHeartbeatBatch(ids, command.tokens) }, requestId);
|
|
55
84
|
}
|
|
56
85
|
export function handlePing(_command, _context, requestId) {
|
|
57
86
|
return response.data({ pong: true, time: Date.now() }, requestId);
|
|
@@ -2,7 +2,7 @@ import type { ClearLogsCommand, CompactMemoryCommand, ExtendLockCommand, ExtendL
|
|
|
2
2
|
import type { Response } from '../../../../domain/types/response';
|
|
3
3
|
import type { HandlerContext } from '../../types';
|
|
4
4
|
export declare function handlePrometheus(_command: PrometheusCommand, context: HandlerContext, requestId?: string): Response;
|
|
5
|
-
export declare function handleClearLogs(command: ClearLogsCommand, context: HandlerContext, requestId?: string): Response
|
|
5
|
+
export declare function handleClearLogs(command: ClearLogsCommand, context: HandlerContext, requestId?: string): Response | Promise<Response>;
|
|
6
6
|
export declare function handleExtendLock(command: ExtendLockCommand, context: HandlerContext, requestId?: string): Promise<Response>;
|
|
7
7
|
export declare function handleExtendLocks(command: ExtendLocksCommand, context: HandlerContext, requestId?: string): Promise<Response>;
|
|
8
8
|
export declare function handleCompactMemory(_command: CompactMemoryCommand, context: HandlerContext, requestId?: string): Response;
|
|
@@ -4,7 +4,14 @@ export function handlePrometheus(_command, context, requestId) {
|
|
|
4
4
|
return response.data({ metrics: context.queueManager.getPrometheusMetrics() }, requestId);
|
|
5
5
|
}
|
|
6
6
|
export function handleClearLogs(command, context, requestId) {
|
|
7
|
-
|
|
7
|
+
const id = jobId(command.id);
|
|
8
|
+
const manager = context.queueManager;
|
|
9
|
+
if (manager.clearLogsDurable) {
|
|
10
|
+
return manager
|
|
11
|
+
.clearLogsDurable(id, command.keepLogs)
|
|
12
|
+
.then(() => response.ok(undefined, requestId));
|
|
13
|
+
}
|
|
14
|
+
manager.clearLogs(id, command.keepLogs);
|
|
8
15
|
return response.ok(undefined, requestId);
|
|
9
16
|
}
|
|
10
17
|
export async function handleExtendLock(command, context, requestId) {
|