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,8 +1,27 @@
|
|
|
1
|
-
import type { JobId } from '../../types/job';
|
|
1
|
+
import type { Job, JobId } from '../../types/job';
|
|
2
|
+
import type { GroupPullOptions, GroupRateLimitOverride } from '../../types/group';
|
|
3
|
+
import type { GroupCandidate } from '../groupScheduler';
|
|
2
4
|
import type { QueueState } from '../../types/queue';
|
|
3
5
|
import { ShardKeys } from './keys';
|
|
4
6
|
/** Queue rate, concurrency, and resource ownership operations. */
|
|
5
7
|
export declare class ShardLimits extends ShardKeys {
|
|
8
|
+
hasGroupScheduler(queue: string): boolean;
|
|
9
|
+
assignGroupFifoOrder(job: Job): void;
|
|
10
|
+
observeGroupFifoOrder(job: Job): void;
|
|
11
|
+
peekGroupCandidate(queue: string, now: number, options?: GroupPullOptions): GroupCandidate;
|
|
12
|
+
acquireGroup(queue: string, groupId: string, options?: GroupPullOptions, now?: number): boolean;
|
|
13
|
+
advanceGroup(queue: string, groupId: string): void;
|
|
14
|
+
getGroupJobsCount(queue: string, groupId: string): number;
|
|
15
|
+
getGroupsJobsCount(queue: string): number;
|
|
16
|
+
cleanExpiredGroupWindows(now: number): void;
|
|
17
|
+
clearEmptyGroupRuntime(queue: string): void;
|
|
18
|
+
setGroupRateLimit(queue: string, groupId: string, max: number, duration: number): void;
|
|
19
|
+
getGroupRateLimit(queue: string, groupId: string): GroupRateLimitOverride | null;
|
|
20
|
+
removeGroupRateLimit(queue: string, groupId: string): number;
|
|
21
|
+
getGroupRateLimitTtl(queue: string, groupId: string, maxJobs?: number): number;
|
|
22
|
+
setGroupConcurrency(queue: string, groupId: string, concurrency: number): void;
|
|
23
|
+
getGroupConcurrency(queue: string, groupId: string): number | null;
|
|
24
|
+
removeGroupConcurrency(queue: string, groupId: string): number;
|
|
6
25
|
setRateLimit(queue: string, limit: number, durationMs?: number, ttlMs?: number): void;
|
|
7
26
|
clearRateLimit(queue: string): void;
|
|
8
27
|
expireRateLimitIfNeeded(queue: string): void;
|
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
import { ShardKeys } from './keys';
|
|
2
2
|
/** Queue rate, concurrency, and resource ownership operations. */
|
|
3
3
|
export class ShardLimits extends ShardKeys {
|
|
4
|
+
hasGroupScheduler(queue) {
|
|
5
|
+
return this.groupScheduler.isActive(queue);
|
|
6
|
+
}
|
|
7
|
+
assignGroupFifoOrder(job) {
|
|
8
|
+
this.groupScheduler.assignFifoOrder(job);
|
|
9
|
+
}
|
|
10
|
+
observeGroupFifoOrder(job) {
|
|
11
|
+
this.groupScheduler.observeFifoOrder(job);
|
|
12
|
+
}
|
|
13
|
+
peekGroupCandidate(queue, now, options) {
|
|
14
|
+
return this.groupScheduler.peek(queue, now, (groupId) => this.groupLimiterManager.status(queue, groupId, options, this.getGroupActiveCount(queue, groupId), now));
|
|
15
|
+
}
|
|
16
|
+
acquireGroup(queue, groupId, options, now) {
|
|
17
|
+
const acquired = this.groupLimiterManager.acquire(queue, groupId, options, this.getGroupActiveCount(queue, groupId), now);
|
|
18
|
+
if (acquired)
|
|
19
|
+
this.activateGroup(queue, groupId);
|
|
20
|
+
return acquired;
|
|
21
|
+
}
|
|
22
|
+
advanceGroup(queue, groupId) {
|
|
23
|
+
this.groupScheduler.advance(queue, groupId);
|
|
24
|
+
}
|
|
25
|
+
getGroupJobsCount(queue, groupId) {
|
|
26
|
+
return this.groupScheduler.getGroupJobsCount(queue, groupId);
|
|
27
|
+
}
|
|
28
|
+
getGroupsJobsCount(queue) {
|
|
29
|
+
return this.groupScheduler.getGroupsJobsCount(queue);
|
|
30
|
+
}
|
|
31
|
+
cleanExpiredGroupWindows(now) {
|
|
32
|
+
this.groupLimiterManager.pruneExpiredWindows(now);
|
|
33
|
+
}
|
|
34
|
+
clearEmptyGroupRuntime(queue) {
|
|
35
|
+
this.groupScheduler.clearQueue(queue);
|
|
36
|
+
this.activeGroups.delete(queue);
|
|
37
|
+
this.activeGroupCounts.delete(queue);
|
|
38
|
+
}
|
|
39
|
+
setGroupRateLimit(queue, groupId, max, duration) {
|
|
40
|
+
this.groupLimiterManager.setRateLimit(queue, groupId, max, duration);
|
|
41
|
+
}
|
|
42
|
+
getGroupRateLimit(queue, groupId) {
|
|
43
|
+
return this.groupLimiterManager.getRateLimit(queue, groupId);
|
|
44
|
+
}
|
|
45
|
+
removeGroupRateLimit(queue, groupId) {
|
|
46
|
+
return this.groupLimiterManager.removeRateLimit(queue, groupId);
|
|
47
|
+
}
|
|
48
|
+
getGroupRateLimitTtl(queue, groupId, maxJobs) {
|
|
49
|
+
return this.groupLimiterManager.getRateLimitTtl(queue, groupId, maxJobs);
|
|
50
|
+
}
|
|
51
|
+
setGroupConcurrency(queue, groupId, concurrency) {
|
|
52
|
+
this.groupLimiterManager.setConcurrency(queue, groupId, concurrency);
|
|
53
|
+
}
|
|
54
|
+
getGroupConcurrency(queue, groupId) {
|
|
55
|
+
return this.groupLimiterManager.getConcurrency(queue, groupId);
|
|
56
|
+
}
|
|
57
|
+
removeGroupConcurrency(queue, groupId) {
|
|
58
|
+
return this.groupLimiterManager.removeConcurrency(queue, groupId);
|
|
59
|
+
}
|
|
4
60
|
setRateLimit(queue, limit, durationMs, ttlMs) {
|
|
5
61
|
this.limiterManager.setRateLimit(queue, limit, durationMs, ttlMs);
|
|
6
62
|
}
|
|
@@ -4,6 +4,8 @@ import { DependencyTracker } from '../dependencyTracker';
|
|
|
4
4
|
import { DlqShard } from '../dlqShard';
|
|
5
5
|
import { LimiterManager } from '../limiterManager';
|
|
6
6
|
import { IndexedPriorityQueue } from '../priorityQueue';
|
|
7
|
+
import { GroupLimiterManager } from '../groupLimiterManager';
|
|
8
|
+
import { GroupScheduler } from '../groupScheduler';
|
|
7
9
|
import { ShardCounters } from '../shardCounters';
|
|
8
10
|
import { TemporalManager } from '../temporalManager';
|
|
9
11
|
import { UniqueKeyManager } from '../uniqueKeyManager';
|
|
@@ -12,9 +14,12 @@ import { WaiterManager } from '../waiterManager';
|
|
|
12
14
|
export declare class ShardState {
|
|
13
15
|
readonly queues: Map<string, IndexedPriorityQueue>;
|
|
14
16
|
readonly activeGroups: Map<string, Set<string>>;
|
|
17
|
+
readonly activeGroupCounts: Map<string, Map<string, number>>;
|
|
15
18
|
protected readonly uniqueKeyManager: UniqueKeyManager;
|
|
16
19
|
protected readonly dlqManager: DlqShard;
|
|
17
20
|
protected readonly limiterManager: LimiterManager;
|
|
21
|
+
protected readonly groupLimiterManager: GroupLimiterManager;
|
|
22
|
+
protected readonly groupScheduler: GroupScheduler;
|
|
18
23
|
protected readonly dependencyTracker: DependencyTracker;
|
|
19
24
|
protected readonly temporalManager: TemporalManager;
|
|
20
25
|
protected readonly waiterManager: WaiterManager;
|
|
@@ -2,6 +2,8 @@ import { DependencyTracker } from '../dependencyTracker';
|
|
|
2
2
|
import { DlqShard } from '../dlqShard';
|
|
3
3
|
import { LimiterManager } from '../limiterManager';
|
|
4
4
|
import { IndexedPriorityQueue } from '../priorityQueue';
|
|
5
|
+
import { GroupLimiterManager } from '../groupLimiterManager';
|
|
6
|
+
import { GroupScheduler } from '../groupScheduler';
|
|
5
7
|
import { ShardCounters } from '../shardCounters';
|
|
6
8
|
import { TemporalManager } from '../temporalManager';
|
|
7
9
|
import { UniqueKeyManager } from '../uniqueKeyManager';
|
|
@@ -10,9 +12,12 @@ import { WaiterManager } from '../waiterManager';
|
|
|
10
12
|
export class ShardState {
|
|
11
13
|
queues = new Map();
|
|
12
14
|
activeGroups = new Map();
|
|
15
|
+
activeGroupCounts = new Map();
|
|
13
16
|
uniqueKeyManager = new UniqueKeyManager();
|
|
14
17
|
dlqManager;
|
|
15
18
|
limiterManager = new LimiterManager();
|
|
19
|
+
groupLimiterManager = new GroupLimiterManager();
|
|
20
|
+
groupScheduler = new GroupScheduler();
|
|
16
21
|
dependencyTracker = new DependencyTracker();
|
|
17
22
|
temporalManager = new TemporalManager();
|
|
18
23
|
waiterManager = new WaiterManager();
|
|
@@ -49,7 +54,10 @@ export class ShardState {
|
|
|
49
54
|
getQueue(name) {
|
|
50
55
|
let queue = this.queues.get(name);
|
|
51
56
|
if (!queue) {
|
|
52
|
-
queue = new IndexedPriorityQueue(
|
|
57
|
+
queue = new IndexedPriorityQueue({
|
|
58
|
+
onInsert: (job) => this.groupScheduler.insert(name, job, () => this.queues.get(name)?.values() ?? []),
|
|
59
|
+
onRemove: (job) => this.groupScheduler.remove(name, job),
|
|
60
|
+
});
|
|
53
61
|
this.queues.set(name, queue);
|
|
54
62
|
}
|
|
55
63
|
return queue;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AtomicFlowJobInput } from '../flow';
|
|
2
2
|
import type { JobInput } from '../job';
|
|
3
|
+
import type { GroupPullOptions } from '../group';
|
|
3
4
|
import type { BaseCommand } from './base';
|
|
4
5
|
export interface PushCommand extends BaseCommand {
|
|
5
6
|
readonly cmd: 'PUSH';
|
|
@@ -72,6 +73,7 @@ export interface PullCommand extends BaseCommand {
|
|
|
72
73
|
readonly owner?: string;
|
|
73
74
|
readonly lockTtl?: number;
|
|
74
75
|
readonly detach?: boolean;
|
|
76
|
+
readonly group?: GroupPullOptions;
|
|
75
77
|
}
|
|
76
78
|
export interface PullBatchCommand extends BaseCommand {
|
|
77
79
|
readonly cmd: 'PULLB';
|
|
@@ -80,6 +82,7 @@ export interface PullBatchCommand extends BaseCommand {
|
|
|
80
82
|
readonly timeout?: number;
|
|
81
83
|
readonly owner?: string;
|
|
82
84
|
readonly lockTtl?: number;
|
|
85
|
+
readonly group?: GroupPullOptions;
|
|
83
86
|
}
|
|
84
87
|
export interface AckCommand extends BaseCommand {
|
|
85
88
|
readonly cmd: 'ACK';
|
|
@@ -21,6 +21,11 @@ export interface PurgeDlqCommand extends BaseCommand {
|
|
|
21
21
|
readonly cmd: 'PurgeDlq';
|
|
22
22
|
readonly queue: string;
|
|
23
23
|
}
|
|
24
|
+
export interface RemoveDlqJobCommand extends BaseCommand {
|
|
25
|
+
readonly cmd: 'RemoveDlqJob';
|
|
26
|
+
readonly queue: string;
|
|
27
|
+
readonly jobId: string;
|
|
28
|
+
}
|
|
24
29
|
export interface RetryCompletedCommand extends BaseCommand {
|
|
25
30
|
readonly cmd: 'RetryCompleted';
|
|
26
31
|
readonly queue: string;
|
|
@@ -52,3 +52,44 @@ export interface GetStallConfigCommand extends BaseCommand {
|
|
|
52
52
|
readonly cmd: 'GetStallConfig';
|
|
53
53
|
readonly queue: string;
|
|
54
54
|
}
|
|
55
|
+
interface GroupCommand extends BaseCommand {
|
|
56
|
+
readonly queue: string;
|
|
57
|
+
readonly groupId: string;
|
|
58
|
+
}
|
|
59
|
+
export interface GetGroupJobsCountCommand extends GroupCommand {
|
|
60
|
+
readonly cmd: 'GetGroupJobsCount';
|
|
61
|
+
}
|
|
62
|
+
export interface GetGroupsJobsCountCommand extends BaseCommand {
|
|
63
|
+
readonly cmd: 'GetGroupsJobsCount';
|
|
64
|
+
readonly queue: string;
|
|
65
|
+
readonly maxCount?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface GetGroupActiveCountCommand extends GroupCommand {
|
|
68
|
+
readonly cmd: 'GetGroupActiveCount';
|
|
69
|
+
}
|
|
70
|
+
export interface SetGroupRateLimitCommand extends GroupCommand {
|
|
71
|
+
readonly cmd: 'SetGroupRateLimit';
|
|
72
|
+
readonly max: number;
|
|
73
|
+
readonly duration: number;
|
|
74
|
+
}
|
|
75
|
+
export interface GetGroupRateLimitCommand extends GroupCommand {
|
|
76
|
+
readonly cmd: 'GetGroupRateLimit';
|
|
77
|
+
}
|
|
78
|
+
export interface RemoveGroupRateLimitCommand extends GroupCommand {
|
|
79
|
+
readonly cmd: 'RemoveGroupRateLimit';
|
|
80
|
+
}
|
|
81
|
+
export interface GetGroupRateLimitTtlCommand extends GroupCommand {
|
|
82
|
+
readonly cmd: 'GetGroupRateLimitTtl';
|
|
83
|
+
readonly maxJobs?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface SetGroupConcurrencyCommand extends GroupCommand {
|
|
86
|
+
readonly cmd: 'SetGroupConcurrency';
|
|
87
|
+
readonly concurrency: number;
|
|
88
|
+
}
|
|
89
|
+
export interface GetGroupConcurrencyCommand extends GroupCommand {
|
|
90
|
+
readonly cmd: 'GetGroupConcurrency';
|
|
91
|
+
}
|
|
92
|
+
export interface RemoveGroupConcurrencyCommand extends GroupCommand {
|
|
93
|
+
readonly cmd: 'RemoveGroupConcurrency';
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
@@ -9,5 +9,5 @@ import type * as Monitoring from './monitoring';
|
|
|
9
9
|
import type * as Protocol from './protocol';
|
|
10
10
|
import type * as Query from './query';
|
|
11
11
|
import type * as Workers from './workers';
|
|
12
|
-
export type Command = Core.PushCommand | Core.PushBatchCommand | Core.PushFlowCommand | Core.PullCommand | Core.PullBatchCommand | Core.AckCommand | Core.AckBatchCommand | Core.FailCommand | Query.GetJobCommand | Query.GetStateCommand | Query.GetResultCommand | Query.GetJobsCommand | Query.GetJobCountsCommand | Query.GetCountsPerPriorityCommand | Query.GetJobByCustomIdCommand | Query.CountCommand | Query.GetProgressCommand | Query.GetChildrenValuesCommand | Management.CancelCommand | Management.ProgressCommand | Management.UpdateCommand | Management.ChangePriorityCommand | Management.PromoteCommand | Management.WaitJobCommand | Management.MoveToDelayedCommand | Management.DiscardCommand | Management.PauseCommand | Management.ResumeCommand | Management.IsPausedCommand | Management.DrainCommand | Management.ObliterateCommand | Management.ListQueuesCommand | Management.CleanCommand | Dlq.DlqCommand | Dlq.GetDlqStatsCommand | Dlq.RetryDlqCommand | Dlq.PurgeDlqCommand | Dlq.RetryCompletedCommand | Dlq.SetDlqConfigCommand | Dlq.GetDlqConfigCommand | Limits.GetQueueLimitsCommand | Limits.GetDeduplicationJobIdCommand | Limits.RemoveDeduplicationKeyCommand | Limits.RemoveJobDeduplicationKeyCommand | Limits.MoveToWaitingChildrenCommand | Limits.RateLimitCommand | Limits.SetConcurrencyCommand | Limits.RateLimitClearCommand | Limits.ClearConcurrencyCommand | Limits.SetStallConfigCommand | Limits.GetStallConfigCommand | Cron.CronCommand | Cron.CronDeleteCommand | Cron.CronListCommand | Cron.CronGetCommand | Monitoring.AddLogCommand | Monitoring.GetLogsCommand | Monitoring.AddWebhookCommand | Monitoring.RemoveWebhookCommand | Monitoring.ListWebhooksCommand | Monitoring.StatsCommand | Monitoring.MetricsCommand | Monitoring.TrimEventsCommand | Monitoring.PrometheusCommand | Monitoring.StorageStatusCommand | Workers.HeartbeatCommand | Workers.JobHeartbeatCommand | Workers.JobHeartbeatBatchCommand | Workers.PingCommand | Workers.RegisterWorkerCommand | Workers.UnregisterWorkerCommand | Workers.ListWorkersCommand | Extended.ClearLogsCommand | Extended.ExtendLockCommand | Extended.ExtendLocksCommand | Extended.ChangeDelayCommand | Extended.SetWebhookEnabledCommand | Extended.CompactMemoryCommand | Extended.UpdateParentCommand | Extended.GetFailedChildrenValuesCommand | Extended.GetIgnoredChildrenFailuresCommand | Extended.RemoveChildDependencyCommand | Extended.RemoveUnprocessedChildrenCommand | Extended.MoveToWaitCommand | Extended.PromoteJobsCommand | Dashboard.DashboardOverviewCommand | Dashboard.DashboardQueuesCommand | Dashboard.DashboardQueueCommand | Protocol.AuthCommand | Protocol.HelloCommand | Protocol.SubscribeEventsCommand | Protocol.UnsubscribeEventsCommand;
|
|
12
|
+
export type Command = Core.PushCommand | Core.PushBatchCommand | Core.PushFlowCommand | Core.PullCommand | Core.PullBatchCommand | Core.AckCommand | Core.AckBatchCommand | Core.FailCommand | Query.GetJobCommand | Query.GetStateCommand | Query.GetResultCommand | Query.GetJobsCommand | Query.GetJobCountsCommand | Query.GetCountsPerPriorityCommand | Query.GetJobByCustomIdCommand | Query.CountCommand | Query.GetProgressCommand | Query.GetChildrenValuesCommand | Management.CancelCommand | Management.ProgressCommand | Management.UpdateCommand | Management.ChangePriorityCommand | Management.PromoteCommand | Management.WaitJobCommand | Management.MoveToDelayedCommand | Management.DiscardCommand | Management.PauseCommand | Management.ResumeCommand | Management.IsPausedCommand | Management.DrainCommand | Management.ObliterateCommand | Management.ListQueuesCommand | Management.CleanCommand | Dlq.DlqCommand | Dlq.GetDlqStatsCommand | Dlq.RetryDlqCommand | Dlq.PurgeDlqCommand | Dlq.RemoveDlqJobCommand | Dlq.RetryCompletedCommand | Dlq.SetDlqConfigCommand | Dlq.GetDlqConfigCommand | Limits.GetQueueLimitsCommand | Limits.GetDeduplicationJobIdCommand | Limits.RemoveDeduplicationKeyCommand | Limits.RemoveJobDeduplicationKeyCommand | Limits.MoveToWaitingChildrenCommand | Limits.RateLimitCommand | Limits.SetConcurrencyCommand | Limits.RateLimitClearCommand | Limits.ClearConcurrencyCommand | Limits.SetStallConfigCommand | Limits.GetStallConfigCommand | Limits.GetGroupJobsCountCommand | Limits.GetGroupsJobsCountCommand | Limits.GetGroupActiveCountCommand | Limits.SetGroupRateLimitCommand | Limits.GetGroupRateLimitCommand | Limits.RemoveGroupRateLimitCommand | Limits.GetGroupRateLimitTtlCommand | Limits.SetGroupConcurrencyCommand | Limits.GetGroupConcurrencyCommand | Limits.RemoveGroupConcurrencyCommand | Cron.CronCommand | Cron.CronDeleteCommand | Cron.CronListCommand | Cron.CronGetCommand | Monitoring.AddLogCommand | Monitoring.GetLogsCommand | Monitoring.AddWebhookCommand | Monitoring.RemoveWebhookCommand | Monitoring.ListWebhooksCommand | Monitoring.StatsCommand | Monitoring.MetricsCommand | Monitoring.TrimEventsCommand | Monitoring.PrometheusCommand | Monitoring.StorageStatusCommand | Workers.HeartbeatCommand | Workers.JobHeartbeatCommand | Workers.JobHeartbeatBatchCommand | Workers.PingCommand | Workers.RegisterWorkerCommand | Workers.UnregisterWorkerCommand | Workers.ListWorkersCommand | Extended.ClearLogsCommand | Extended.ExtendLockCommand | Extended.ExtendLocksCommand | Extended.ChangeDelayCommand | Extended.SetWebhookEnabledCommand | Extended.CompactMemoryCommand | Extended.UpdateParentCommand | Extended.GetFailedChildrenValuesCommand | Extended.GetIgnoredChildrenFailuresCommand | Extended.RemoveChildDependencyCommand | Extended.RemoveUnprocessedChildrenCommand | Extended.MoveToWaitCommand | Extended.PromoteJobsCommand | Dashboard.DashboardOverviewCommand | Dashboard.DashboardQueuesCommand | Dashboard.DashboardQueueCommand | Protocol.AuthCommand | Protocol.HelloCommand | Protocol.SubscribeEventsCommand | Protocol.UnsubscribeEventsCommand;
|
|
13
13
|
export type CommandType = Command['cmd'];
|
|
@@ -78,6 +78,11 @@ export interface CronJobInput {
|
|
|
78
78
|
/** Job options applied to each spawned job (retry/cleanup policy, etc.) */
|
|
79
79
|
jobOptions?: CronJobOptions;
|
|
80
80
|
}
|
|
81
|
+
/** Validate the calendar/interval timing fields before scheduler mutation. */
|
|
82
|
+
export declare function assertValidCronTiming(input: {
|
|
83
|
+
readonly schedule?: string | null;
|
|
84
|
+
readonly repeatEvery?: number | null;
|
|
85
|
+
}): void;
|
|
81
86
|
/** Create a new cron job */
|
|
82
87
|
export declare function createCronJob(input: CronJobInput, nextRun: number): CronJob;
|
|
83
88
|
/** Check if cron job has reached its execution limit */
|
|
@@ -2,11 +2,22 @@
|
|
|
2
2
|
* Cron job domain types
|
|
3
3
|
*/
|
|
4
4
|
import { normalizeJobPayload } from '../job/payload';
|
|
5
|
-
/**
|
|
6
|
-
export function
|
|
7
|
-
if (
|
|
5
|
+
/** Validate the calendar/interval timing fields before scheduler mutation. */
|
|
6
|
+
export function assertValidCronTiming(input) {
|
|
7
|
+
if (input.repeatEvery !== undefined && input.repeatEvery !== null) {
|
|
8
|
+
if (typeof input.repeatEvery !== 'number' ||
|
|
9
|
+
!Number.isSafeInteger(input.repeatEvery) ||
|
|
10
|
+
input.repeatEvery < 1) {
|
|
11
|
+
throw new Error('Cron repeatEvery must be a positive safe integer number of milliseconds');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (!input.schedule && (input.repeatEvery === undefined || input.repeatEvery === null)) {
|
|
8
15
|
throw new Error('Cron job must have either schedule or repeatEvery');
|
|
9
16
|
}
|
|
17
|
+
}
|
|
18
|
+
/** Create a new cron job */
|
|
19
|
+
export function createCronJob(input, nextRun) {
|
|
20
|
+
assertValidCronTiming(input);
|
|
10
21
|
const payload = normalizeJobPayload({ name: input.jobName, data: input.data });
|
|
11
22
|
return {
|
|
12
23
|
name: input.name,
|
|
@@ -89,7 +89,7 @@ export interface DlqConfig {
|
|
|
89
89
|
/** Default DLQ configuration */
|
|
90
90
|
export declare const DEFAULT_DLQ_CONFIG: DlqConfig;
|
|
91
91
|
/** Create a DLQ entry from a failed job */
|
|
92
|
-
export declare function createDlqEntry(job: Job, reason: FailureReason, error: string | null, config?: DlqConfig): DlqEntry;
|
|
92
|
+
export declare function createDlqEntry(job: Job, reason: FailureReason, error: string | null, config?: DlqConfig, now?: number): DlqEntry;
|
|
93
93
|
/** Add attempt record to existing DLQ entry */
|
|
94
94
|
export declare function addAttemptRecord(entry: DlqEntry, reason: FailureReason, error: string | null): void;
|
|
95
95
|
/** Check if DLQ entry is expired */
|
package/dist/domain/types/dlq.js
CHANGED
|
@@ -63,8 +63,7 @@ export const DEFAULT_DLQ_CONFIG = {
|
|
|
63
63
|
maxEntries: 10000,
|
|
64
64
|
};
|
|
65
65
|
/** Create a DLQ entry from a failed job */
|
|
66
|
-
export function createDlqEntry(job, reason, error, config = DEFAULT_DLQ_CONFIG) {
|
|
67
|
-
const now = Date.now();
|
|
66
|
+
export function createDlqEntry(job, reason, error, config = DEFAULT_DLQ_CONFIG, now = Date.now()) {
|
|
68
67
|
const retained = getDlqRetryState(job);
|
|
69
68
|
const alreadyEntered = retained?.enteredAt !== null && retained?.enteredAt !== undefined;
|
|
70
69
|
const attemptRecord = createAttemptRecord(job, reason, error, now);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface GroupRateLimit {
|
|
2
|
+
readonly max: number;
|
|
3
|
+
readonly duration: number;
|
|
4
|
+
}
|
|
5
|
+
/** Worker-side defaults enforced authoritatively by the broker. */
|
|
6
|
+
export interface GroupPullOptions {
|
|
7
|
+
readonly concurrency?: number;
|
|
8
|
+
readonly limit?: GroupRateLimit;
|
|
9
|
+
}
|
|
10
|
+
export interface GroupRateLimitOverride extends GroupRateLimit {
|
|
11
|
+
}
|
|
12
|
+
/** Validate the canonical string form shared by every broker and persistence backend. */
|
|
13
|
+
export declare function validateGroupId(value: unknown, required?: boolean): string | null;
|
|
14
|
+
export declare function assertGroupId(value: unknown): asserts value is string;
|
|
15
|
+
export declare function assertOptionalGroupId(value: unknown): asserts value is string | undefined;
|
|
16
|
+
/** Normalize BullMQ-compatible numeric IDs without accepting arbitrary coercion. */
|
|
17
|
+
export declare function normalizeGroupId(value: unknown): string;
|
|
18
|
+
export declare function validatePositiveSafeInteger(value: unknown, name: string): string | null;
|
|
19
|
+
export declare function assertPositiveSafeInteger(value: unknown, name: string): asserts value is number;
|
|
20
|
+
export declare function validateGroupPullOptions(options: unknown): string | null;
|
|
21
|
+
export declare function assertGroupPullOptions(options: unknown): asserts options is GroupPullOptions;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Validate the canonical string form shared by every broker and persistence backend. */
|
|
2
|
+
export function validateGroupId(value, required = false) {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return required ? 'groupId is required' : null;
|
|
5
|
+
if (typeof value !== 'string')
|
|
6
|
+
return 'groupId must be a string';
|
|
7
|
+
if (value.length === 0)
|
|
8
|
+
return 'groupId must be a non-empty string';
|
|
9
|
+
if (value.length > 256)
|
|
10
|
+
return 'groupId must be at most 256 characters';
|
|
11
|
+
if (value.includes('\0'))
|
|
12
|
+
return 'groupId must not contain NUL characters';
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
export function assertGroupId(value) {
|
|
16
|
+
const error = validateGroupId(value, true);
|
|
17
|
+
if (error)
|
|
18
|
+
throw new Error(error);
|
|
19
|
+
}
|
|
20
|
+
export function assertOptionalGroupId(value) {
|
|
21
|
+
const error = validateGroupId(value);
|
|
22
|
+
if (error)
|
|
23
|
+
throw new Error(error);
|
|
24
|
+
}
|
|
25
|
+
/** Normalize BullMQ-compatible numeric IDs without accepting arbitrary coercion. */
|
|
26
|
+
export function normalizeGroupId(value) {
|
|
27
|
+
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
28
|
+
throw new Error('groupId must be a string or number');
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'number' && !Number.isSafeInteger(value)) {
|
|
31
|
+
throw new Error('numeric groupId must be a safe integer');
|
|
32
|
+
}
|
|
33
|
+
const groupId = String(value);
|
|
34
|
+
assertGroupId(groupId);
|
|
35
|
+
return groupId;
|
|
36
|
+
}
|
|
37
|
+
export function validatePositiveSafeInteger(value, name) {
|
|
38
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0) {
|
|
39
|
+
return `${name} must be a positive safe integer`;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
export function assertPositiveSafeInteger(value, name) {
|
|
44
|
+
const error = validatePositiveSafeInteger(value, name);
|
|
45
|
+
if (error)
|
|
46
|
+
throw new Error(error);
|
|
47
|
+
}
|
|
48
|
+
export function validateGroupPullOptions(options) {
|
|
49
|
+
if (options === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
52
|
+
return 'group must be an object';
|
|
53
|
+
}
|
|
54
|
+
const group = options;
|
|
55
|
+
if (group.concurrency !== undefined) {
|
|
56
|
+
const error = validatePositiveSafeInteger(group.concurrency, 'group.concurrency');
|
|
57
|
+
if (error)
|
|
58
|
+
return error;
|
|
59
|
+
}
|
|
60
|
+
if (group.limit !== undefined) {
|
|
61
|
+
if (!group.limit || typeof group.limit !== 'object' || Array.isArray(group.limit)) {
|
|
62
|
+
return 'group.limit must be an object';
|
|
63
|
+
}
|
|
64
|
+
const limit = group.limit;
|
|
65
|
+
const maxError = validatePositiveSafeInteger(limit.max, 'group.limit.max');
|
|
66
|
+
if (maxError)
|
|
67
|
+
return maxError;
|
|
68
|
+
const durationError = validatePositiveSafeInteger(limit.duration, 'group.limit.duration');
|
|
69
|
+
if (durationError)
|
|
70
|
+
return durationError;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
export function assertGroupPullOptions(options) {
|
|
75
|
+
const error = validateGroupPullOptions(options);
|
|
76
|
+
if (error)
|
|
77
|
+
throw new Error(error);
|
|
78
|
+
}
|
|
@@ -83,7 +83,7 @@ export interface Job {
|
|
|
83
83
|
readonly deduplicationReplace: boolean;
|
|
84
84
|
readonly debounceId: string | null;
|
|
85
85
|
readonly debounceTtl: number | null;
|
|
86
|
-
/** Whether
|
|
86
|
+
/** Whether SQLite admission bypasses its write buffer; PostgreSQL is always transactional. */
|
|
87
87
|
readonly durable?: boolean;
|
|
88
88
|
timeline: JobTimelineEntry[];
|
|
89
89
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { cloudLog } from './logger';
|
|
9
9
|
import { COMMANDS } from './commands';
|
|
10
|
+
import { resolveCloudQueueAdapter } from './queueAdapter/registry';
|
|
11
|
+
import { sanitizeServerError } from '../server/errors';
|
|
10
12
|
/**
|
|
11
13
|
* Normalize object keys: PascalCase/UpperCase → camelCase.
|
|
12
14
|
* Skips user data fields (data, result, backoffConfig, repeat) — those are passed as-is.
|
|
@@ -51,7 +53,7 @@ export async function handleCommand(queueManager, cmd, context) {
|
|
|
51
53
|
type: 'command_result',
|
|
52
54
|
id: cmd.id,
|
|
53
55
|
success: false,
|
|
54
|
-
error:
|
|
56
|
+
error: sanitizeServerError(err),
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -66,7 +68,7 @@ export async function handleCommand(queueManager, cmd, context) {
|
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
70
|
try {
|
|
69
|
-
const raw = await handler(queueManager, cmd, context);
|
|
71
|
+
const raw = await handler(resolveCloudQueueAdapter(queueManager), cmd, context);
|
|
70
72
|
const data = camelKeys(raw);
|
|
71
73
|
cloudLog.info('Remote command executed', { action: cmd.action, id: cmd.id });
|
|
72
74
|
return { type: 'command_result', id: cmd.id, success: true, data };
|
|
@@ -81,7 +83,7 @@ export async function handleCommand(queueManager, cmd, context) {
|
|
|
81
83
|
type: 'command_result',
|
|
82
84
|
id: cmd.id,
|
|
83
85
|
success: false,
|
|
84
|
-
error:
|
|
86
|
+
error: sanitizeServerError(err),
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const INTEGRATION_COMMANDS = {
|
|
2
|
-
'cron:upsert': (
|
|
3
|
-
|
|
4
|
-
const cron =
|
|
2
|
+
'cron:upsert': async (adapter, command) => {
|
|
3
|
+
await adapter.removeCron(command.name ?? '');
|
|
4
|
+
const cron = await adapter.addCron({
|
|
5
5
|
name: command.name ?? '',
|
|
6
6
|
jobName: 'default',
|
|
7
7
|
queue: command.queue ?? '',
|
|
@@ -10,18 +10,18 @@ export const INTEGRATION_COMMANDS = {
|
|
|
10
10
|
});
|
|
11
11
|
return { name: cron.name, nextRun: cron.nextRun };
|
|
12
12
|
},
|
|
13
|
-
'cron:delete': (
|
|
14
|
-
deleted:
|
|
13
|
+
'cron:delete': async (adapter, command) => ({
|
|
14
|
+
deleted: await adapter.removeCron(command.name ?? ''),
|
|
15
15
|
}),
|
|
16
|
-
'webhook:add': (
|
|
17
|
-
const webhook =
|
|
16
|
+
'webhook:add': (adapter, command) => {
|
|
17
|
+
const webhook = adapter.manager.webhookManager.add(command.url ?? '', command.events ?? [], command.queue ?? undefined, command.secret ?? undefined);
|
|
18
18
|
return { id: webhook.id, url: webhook.url, events: webhook.events };
|
|
19
19
|
},
|
|
20
|
-
'webhook:remove': (
|
|
21
|
-
removed:
|
|
20
|
+
'webhook:remove': (adapter, command) => ({
|
|
21
|
+
removed: adapter.manager.webhookManager.remove(command.webhookId ?? ''),
|
|
22
22
|
}),
|
|
23
|
-
'webhook:set-enabled': (
|
|
24
|
-
updated:
|
|
23
|
+
'webhook:set-enabled': (adapter, command) => ({
|
|
24
|
+
updated: adapter.manager.webhookManager.setEnabled(command.webhookId ?? '', command.enabled ?? true),
|
|
25
25
|
}),
|
|
26
26
|
's3:backup': async (_queueManager, _command, context) => {
|
|
27
27
|
if (!context?.triggerBackup)
|