bunqueue 2.8.60 → 2.9.0
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 +108 -76
- package/dist/application/background/dlq.js +2 -0
- package/dist/application/contextFactory.js +5 -0
- package/dist/application/dlqManager.d.ts +10 -0
- package/dist/application/dlqManager.js +47 -9
- package/dist/application/dlqRetry.js +59 -38
- package/dist/application/eventsManager.d.ts +1 -1
- package/dist/application/eventsManager.js +30 -26
- package/dist/application/operations/jobManagement.d.ts +4 -0
- package/dist/application/operations/jobMoveOperations.js +9 -4
- 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 +26 -0
- package/dist/application/postgres-queue-manager/control.js +186 -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 +19 -0
- package/dist/application/postgres-queue-manager/delivery.js +80 -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/flow-failures.js +4 -0
- package/dist/application/queue-manager/limits.d.ts +2 -0
- package/dist/application/queue-manager/limits.js +4 -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 +16 -1
- package/dist/cli/commands/server.js +1 -1
- package/dist/client/forwarder.d.ts +6 -4
- package/dist/client/forwarder.js +5 -3
- 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/runtime/configuration.d.ts +4 -0
- package/dist/client/queue/runtime/configuration.js +8 -0
- package/dist/client/worker/runtime/execution.js +3 -8
- package/dist/client/worker/runtime/polling.d.ts +1 -0
- package/dist/client/worker/runtime/polling.js +9 -0
- 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/queue/dlqShard.d.ts +2 -0
- package/dist/domain/queue/dlqShard.js +16 -0
- package/dist/domain/queue/shard/dlq.d.ts +1 -0
- package/dist/domain/queue/shard/dlq.js +3 -0
- package/dist/domain/types/commands/dlq.d.ts +5 -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/jobs/model.d.ts +1 -1
- 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/postgres/admission.d.ts +18 -0
- package/dist/infrastructure/persistence/postgres/admission.js +193 -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 +110 -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 +11 -0
- package/dist/infrastructure/persistence/postgres/claimBatch.js +56 -0
- package/dist/infrastructure/persistence/postgres/claimSelection.d.ts +4 -0
- package/dist/infrastructure/persistence/postgres/claimSelection.js +198 -0
- package/dist/infrastructure/persistence/postgres/claims.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/claims.js +137 -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/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 +253 -0
- package/dist/infrastructure/persistence/postgres/eventPruneWatermarks.d.ts +24 -0
- package/dist/infrastructure/persistence/postgres/eventPruneWatermarks.js +111 -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 +249 -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/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 +154 -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 +46 -0
- package/dist/infrastructure/persistence/postgres/runtime.js +236 -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 +257 -0
- package/dist/infrastructure/persistence/postgres/schemaInitialization.d.ts +3 -0
- package/dist/infrastructure/persistence/postgres/schemaInitialization.js +221 -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 +90 -0
- package/dist/infrastructure/persistence/postgres/store.js +136 -0
- package/dist/infrastructure/persistence/postgres/telemetry.d.ts +6 -0
- package/dist/infrastructure/persistence/postgres/telemetry.js +88 -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 +175 -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/sqlite/jobs.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 +3 -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.js +32 -31
- 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/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 +52 -7
- 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/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 +74 -65
|
@@ -18,6 +18,8 @@ export declare function retryDlqByFilterEmbedded(queue: string, filter: DlqFilte
|
|
|
18
18
|
export declare function retryDlqEmbedded(queue: string, id?: string): number;
|
|
19
19
|
/** Purge DLQ (embedded) */
|
|
20
20
|
export declare function purgeDlqEmbedded(queue: string): number;
|
|
21
|
+
/** Remove one DLQ entry in embedded mode. */
|
|
22
|
+
export declare function removeDlqJobEmbedded(queue: string, id: string): boolean;
|
|
21
23
|
/** Set stall config (embedded only) */
|
|
22
24
|
export declare function setStallConfigEmbedded(queue: string, config: Record<string, unknown>): void;
|
|
23
25
|
/** Get stall config (embedded only) */
|
|
@@ -50,6 +50,10 @@ export function retryDlqEmbedded(queue, id) {
|
|
|
50
50
|
export function purgeDlqEmbedded(queue) {
|
|
51
51
|
return getSharedManager().purgeDlq(queue);
|
|
52
52
|
}
|
|
53
|
+
/** Remove one DLQ entry in embedded mode. */
|
|
54
|
+
export function removeDlqJobEmbedded(queue, id) {
|
|
55
|
+
return getSharedManager().removeDlqJob(queue, jobId(id));
|
|
56
|
+
}
|
|
53
57
|
/** Set stall config (embedded only) */
|
|
54
58
|
export function setStallConfigEmbedded(queue, config) {
|
|
55
59
|
const manager = getSharedManager();
|
|
@@ -20,6 +20,8 @@ export function getDlqContext(manager) {
|
|
|
20
20
|
shards: getShards(manager),
|
|
21
21
|
jobIndex: manager.getJobIndex(),
|
|
22
22
|
jobResults: manager.jobResults,
|
|
23
|
+
dependencyResults: manager.dependencyResults,
|
|
24
|
+
customIdMap: manager.customIdMap,
|
|
23
25
|
jobLogs: manager.jobLogs,
|
|
24
26
|
// #110-class: without storage, retryDlqByFilter's deleteDlqEntry/insertJob
|
|
25
27
|
// silently no-op — filtered retries were never persisted in embedded mode
|
|
@@ -21,6 +21,10 @@ export declare class QueueConfiguration<T> extends QueueControl<T> {
|
|
|
21
21
|
retryDlqByFilterAsync(filter: DlqFilter): Promise<number>;
|
|
22
22
|
purgeDlq(): number;
|
|
23
23
|
purgeDlqAsync(): Promise<number>;
|
|
24
|
+
/** Remove one DLQ entry and resolve when the removal completes. */
|
|
25
|
+
removeDlqJob(id: string): Promise<boolean>;
|
|
26
|
+
/** Explicit async alias for removeDlqJob. */
|
|
27
|
+
removeDlqJobAsync(id: string): Promise<boolean>;
|
|
24
28
|
retryCompleted(id?: string): number;
|
|
25
29
|
retryCompletedAsync(id?: string): Promise<number>;
|
|
26
30
|
setGlobalConcurrency(concurrency: number): void;
|
|
@@ -61,6 +61,14 @@ export class QueueConfiguration extends QueueControl {
|
|
|
61
61
|
purgeDlqAsync() {
|
|
62
62
|
return dlqOps.purgeDlqAsync(this.ctx);
|
|
63
63
|
}
|
|
64
|
+
/** Remove one DLQ entry and resolve when the removal completes. */
|
|
65
|
+
removeDlqJob(id) {
|
|
66
|
+
return dlqOps.removeDlqJobAsync(this.ctx, id);
|
|
67
|
+
}
|
|
68
|
+
/** Explicit async alias for removeDlqJob. */
|
|
69
|
+
removeDlqJobAsync(id) {
|
|
70
|
+
return this.removeDlqJob(id);
|
|
71
|
+
}
|
|
64
72
|
retryCompleted(id) {
|
|
65
73
|
return dlqOps.retryCompleted(this.ctx, id);
|
|
66
74
|
}
|
|
@@ -39,15 +39,10 @@ export class WorkerExecution extends WorkerPolling {
|
|
|
39
39
|
if (this.groupLimiter)
|
|
40
40
|
this.groupLimiter.decrement(job);
|
|
41
41
|
if (this.running && !this._closing)
|
|
42
|
-
this.
|
|
42
|
+
this.scheduleProcessing();
|
|
43
43
|
});
|
|
44
|
-
if (this.activeJobs < this.opts.concurrency && !this._closing
|
|
45
|
-
this.
|
|
46
|
-
setImmediate(() => {
|
|
47
|
-
this.processingScheduled = false;
|
|
48
|
-
void this.tryProcess();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
44
|
+
if (this.activeJobs < this.opts.concurrency && !this._closing)
|
|
45
|
+
this.scheduleProcessing();
|
|
51
46
|
return true;
|
|
52
47
|
}
|
|
53
48
|
registerWithServer() {
|
|
@@ -3,6 +3,7 @@ import { WorkerBuffer } from './buffer';
|
|
|
3
3
|
import type { PulledJob, WorkerDelivery } from './state';
|
|
4
4
|
export declare abstract class WorkerPolling<T = unknown, R = unknown> extends WorkerBuffer<T, R> {
|
|
5
5
|
protected poll(): void;
|
|
6
|
+
protected scheduleProcessing(): void;
|
|
6
7
|
protected tryProcess(): Promise<void>;
|
|
7
8
|
protected doPullBatch(): Promise<PulledJob[]>;
|
|
8
9
|
private scheduleRateLimitPoll;
|
|
@@ -16,6 +16,15 @@ export class WorkerPolling extends WorkerBuffer {
|
|
|
16
16
|
}
|
|
17
17
|
void this.tryProcess();
|
|
18
18
|
}
|
|
19
|
+
scheduleProcessing() {
|
|
20
|
+
if (!this.running || this._closing || this.processingScheduled)
|
|
21
|
+
return;
|
|
22
|
+
this.processingScheduled = true;
|
|
23
|
+
setImmediate(() => {
|
|
24
|
+
this.processingScheduled = false;
|
|
25
|
+
void this.tryProcess();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
19
28
|
async tryProcess() {
|
|
20
29
|
if (!this.running || this._closing)
|
|
21
30
|
return;
|
package/dist/config/resolve.d.ts
CHANGED
|
@@ -16,6 +16,20 @@ export interface ResolvedConfig {
|
|
|
16
16
|
tlsKeyFile: string | undefined;
|
|
17
17
|
authTokens: string[];
|
|
18
18
|
dataPath: string | undefined;
|
|
19
|
+
storageDriver: 'memory' | 'sqlite' | 'postgres';
|
|
20
|
+
postgresUrl: string | undefined;
|
|
21
|
+
postgresNamespace: string;
|
|
22
|
+
postgresBrokerId: string | undefined;
|
|
23
|
+
postgresPoolSize: number;
|
|
24
|
+
postgresLeaseDurationMs: number;
|
|
25
|
+
postgresPollIntervalMs: number;
|
|
26
|
+
postgresStatementTimeoutMs: number;
|
|
27
|
+
postgresLockTimeoutMs: number;
|
|
28
|
+
postgresIdleTransactionTimeoutMs: number;
|
|
29
|
+
postgresMaxConcurrentOperations: number;
|
|
30
|
+
postgresMaxQueuedOperations: number;
|
|
31
|
+
postgresMaxSnapshotJobs: number;
|
|
32
|
+
postgresMaxSnapshotPayloadBytes: number;
|
|
19
33
|
corsOrigins: string[];
|
|
20
34
|
requireAuthForMetrics: boolean;
|
|
21
35
|
maxPrometheusQueues: number;
|
package/dist/config/resolve.js
CHANGED
|
@@ -8,6 +8,19 @@ import { DEFAULTS as S3_DEFAULTS } from '../infrastructure/backup/s3BackupConfig
|
|
|
8
8
|
/** Resolve server config: config file > env vars > defaults */
|
|
9
9
|
export function resolveServerConfig(fileConfig) {
|
|
10
10
|
const fc = fileConfig;
|
|
11
|
+
const dataPath = fc?.storage?.dataPath ??
|
|
12
|
+
Bun.env.BUNQUEUE_DATA_PATH ??
|
|
13
|
+
Bun.env.BQ_DATA_PATH ??
|
|
14
|
+
Bun.env.DATA_PATH ??
|
|
15
|
+
Bun.env.SQLITE_PATH;
|
|
16
|
+
const postgresUrl = fc?.storage?.url ?? Bun.env.BUNQUEUE_POSTGRES_URL;
|
|
17
|
+
const storageDriver = fc?.storage?.driver
|
|
18
|
+
? resolveStorageDriver(fc.storage.driver, postgresUrl, dataPath)
|
|
19
|
+
: fc?.storage?.url
|
|
20
|
+
? 'postgres'
|
|
21
|
+
: fc?.storage?.dataPath
|
|
22
|
+
? 'sqlite'
|
|
23
|
+
: resolveStorageDriver(Bun.env.BUNQUEUE_STORAGE_DRIVER, postgresUrl, dataPath);
|
|
11
24
|
return {
|
|
12
25
|
tcpPort: fc?.server?.tcpPort ?? parseInt(Bun.env.TCP_PORT ?? '6789', 10),
|
|
13
26
|
httpPort: fc?.server?.httpPort ?? parseInt(Bun.env.HTTP_PORT ?? '6790', 10),
|
|
@@ -17,11 +30,30 @@ export function resolveServerConfig(fileConfig) {
|
|
|
17
30
|
tlsCertFile: fc?.server?.tlsCertFile ?? Bun.env.TLS_CERT_FILE,
|
|
18
31
|
tlsKeyFile: fc?.server?.tlsKeyFile ?? Bun.env.TLS_KEY_FILE,
|
|
19
32
|
authTokens: fc?.auth?.tokens ?? Bun.env.AUTH_TOKENS?.split(',').filter(Boolean) ?? [],
|
|
20
|
-
dataPath
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
dataPath,
|
|
34
|
+
storageDriver,
|
|
35
|
+
postgresUrl,
|
|
36
|
+
postgresNamespace: fc?.storage?.namespace ?? Bun.env.BUNQUEUE_POSTGRES_NAMESPACE ?? 'default',
|
|
37
|
+
postgresBrokerId: fc?.storage?.brokerId ?? Bun.env.BUNQUEUE_BROKER_ID,
|
|
38
|
+
postgresPoolSize: positiveInteger(fc?.storage?.poolSize ?? parseInt(Bun.env.BUNQUEUE_POSTGRES_POOL_SIZE ?? '4', 10), 4),
|
|
39
|
+
postgresLeaseDurationMs: positiveInteger(fc?.storage?.leaseDurationMs ??
|
|
40
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_LEASE_DURATION_MS ?? '30000', 10), 30_000),
|
|
41
|
+
postgresPollIntervalMs: positiveInteger(fc?.storage?.pollIntervalMs ??
|
|
42
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_POLL_INTERVAL_MS ?? '250', 10), 250),
|
|
43
|
+
postgresStatementTimeoutMs: positiveInteger(fc?.storage?.statementTimeoutMs ??
|
|
44
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_STATEMENT_TIMEOUT_MS ?? '30000', 10), 30_000),
|
|
45
|
+
postgresLockTimeoutMs: positiveInteger(fc?.storage?.lockTimeoutMs ??
|
|
46
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_LOCK_TIMEOUT_MS ?? '5000', 10), 5_000),
|
|
47
|
+
postgresIdleTransactionTimeoutMs: positiveInteger(fc?.storage?.idleTransactionTimeoutMs ??
|
|
48
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_IDLE_TRANSACTION_TIMEOUT_MS ?? '30000', 10), 30_000),
|
|
49
|
+
postgresMaxConcurrentOperations: positiveInteger(fc?.storage?.maxConcurrentOperations ??
|
|
50
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_MAX_CONCURRENT_OPERATIONS ?? '16', 10), 16),
|
|
51
|
+
postgresMaxQueuedOperations: nonNegativeInteger(fc?.storage?.maxQueuedOperations ??
|
|
52
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_MAX_QUEUED_OPERATIONS ?? '128', 10), 128),
|
|
53
|
+
postgresMaxSnapshotJobs: positiveInteger(fc?.storage?.maxSnapshotJobs ??
|
|
54
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_MAX_SNAPSHOT_JOBS ?? '100000', 10), 100_000),
|
|
55
|
+
postgresMaxSnapshotPayloadBytes: positiveInteger(fc?.storage?.maxSnapshotPayloadBytes ??
|
|
56
|
+
parseInt(Bun.env.BUNQUEUE_POSTGRES_MAX_SNAPSHOT_PAYLOAD_BYTES ?? '268435456', 10), 256 * 1024 * 1024),
|
|
25
57
|
corsOrigins: fc?.cors?.origins ?? Bun.env.CORS_ALLOW_ORIGIN?.split(',').filter(Boolean) ?? [],
|
|
26
58
|
requireAuthForMetrics: fc?.auth?.requireAuthForMetrics ?? Bun.env.METRICS_AUTH === 'true',
|
|
27
59
|
maxPrometheusQueues: nonNegativeInteger(fc?.telemetry?.maxPrometheusQueues ?? parseInt(Bun.env.METRICS_MAX_QUEUES ?? '100', 10), 100),
|
|
@@ -31,9 +63,22 @@ export function resolveServerConfig(fileConfig) {
|
|
|
31
63
|
statsIntervalMs: fc?.timeouts?.stats ?? parseInt(Bun.env.STATS_INTERVAL_MS ?? '300000', 10),
|
|
32
64
|
};
|
|
33
65
|
}
|
|
66
|
+
function resolveStorageDriver(configured, postgresUrl, dataPath) {
|
|
67
|
+
if (configured === 'memory' || configured === 'sqlite' || configured === 'postgres') {
|
|
68
|
+
return configured;
|
|
69
|
+
}
|
|
70
|
+
if (configured)
|
|
71
|
+
throw new Error(`Unsupported storage driver: ${configured}`);
|
|
72
|
+
if (postgresUrl)
|
|
73
|
+
return 'postgres';
|
|
74
|
+
return dataPath ? 'sqlite' : 'memory';
|
|
75
|
+
}
|
|
34
76
|
function nonNegativeInteger(value, fallback) {
|
|
35
77
|
return Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
36
78
|
}
|
|
79
|
+
function positiveInteger(value, fallback) {
|
|
80
|
+
return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
81
|
+
}
|
|
37
82
|
/**
|
|
38
83
|
* Resolve server TLS options from resolved config. Returns null when TLS is
|
|
39
84
|
* not configured; throws when only one of cert/key is set (fail fast at
|
package/dist/config/types.d.ts
CHANGED
|
@@ -20,7 +20,25 @@ export interface BunqueueConfig {
|
|
|
20
20
|
requireAuthForMetrics?: boolean;
|
|
21
21
|
};
|
|
22
22
|
storage?: {
|
|
23
|
+
/** Persistence backend. Inferred from url/dataPath when omitted. */
|
|
24
|
+
driver?: 'memory' | 'sqlite' | 'postgres';
|
|
23
25
|
dataPath?: string;
|
|
26
|
+
/** PostgreSQL connection URL. Required when driver is postgres. */
|
|
27
|
+
url?: string;
|
|
28
|
+
/** Isolates independent bunqueue installations sharing one PostgreSQL database. */
|
|
29
|
+
namespace?: string;
|
|
30
|
+
/** Stable identifier for this broker process; generated automatically when omitted. */
|
|
31
|
+
brokerId?: string;
|
|
32
|
+
poolSize?: number;
|
|
33
|
+
leaseDurationMs?: number;
|
|
34
|
+
pollIntervalMs?: number;
|
|
35
|
+
statementTimeoutMs?: number;
|
|
36
|
+
lockTimeoutMs?: number;
|
|
37
|
+
idleTransactionTimeoutMs?: number;
|
|
38
|
+
maxConcurrentOperations?: number;
|
|
39
|
+
maxQueuedOperations?: number;
|
|
40
|
+
maxSnapshotJobs?: number;
|
|
41
|
+
maxSnapshotPayloadBytes?: number;
|
|
24
42
|
};
|
|
25
43
|
telemetry?: {
|
|
26
44
|
/** Maximum queue label values exposed to Prometheus; zero disables per-queue series. */
|
|
@@ -44,6 +44,8 @@ export declare class DlqShard {
|
|
|
44
44
|
getFiltered(queue: string, filter: DlqFilter): DlqEntry[];
|
|
45
45
|
/** Remove entry from DLQ by job ID */
|
|
46
46
|
remove(queue: string, jobId: JobId): DlqEntry | null;
|
|
47
|
+
/** Remove every entry with the same job ID from one queue. */
|
|
48
|
+
removeAll(queue: string, jobId: JobId): DlqEntry[];
|
|
47
49
|
/** Get entries ready for auto-retry */
|
|
48
50
|
getAutoRetryEntries(queue: string, now?: number): DlqEntry[];
|
|
49
51
|
/** Get expired entries for cleanup */
|
|
@@ -135,6 +135,22 @@ export class DlqShard {
|
|
|
135
135
|
this.stats.decrementDlq();
|
|
136
136
|
return entries.splice(idx, 1)[0];
|
|
137
137
|
}
|
|
138
|
+
/** Remove every entry with the same job ID from one queue. */
|
|
139
|
+
removeAll(queue, jobId) {
|
|
140
|
+
const entries = this.dlq.get(queue);
|
|
141
|
+
if (!entries)
|
|
142
|
+
return [];
|
|
143
|
+
const removed = [];
|
|
144
|
+
const remaining = [];
|
|
145
|
+
for (const entry of entries) {
|
|
146
|
+
(entry.job.id === jobId ? removed : remaining).push(entry);
|
|
147
|
+
}
|
|
148
|
+
if (removed.length === 0)
|
|
149
|
+
return removed;
|
|
150
|
+
this.dlq.set(queue, remaining);
|
|
151
|
+
this.stats.decrementDlq(removed.length);
|
|
152
|
+
return removed;
|
|
153
|
+
}
|
|
138
154
|
/** Get entries ready for auto-retry */
|
|
139
155
|
getAutoRetryEntries(queue, now = Date.now()) {
|
|
140
156
|
const entries = this.dlq.get(queue);
|
|
@@ -18,6 +18,7 @@ export declare class ShardDlq extends ShardDependencies {
|
|
|
18
18
|
getDlq(queue: string, count?: number): Job[];
|
|
19
19
|
getDlqFiltered(queue: string, filter: DlqFilter): DlqEntry[];
|
|
20
20
|
removeFromDlq(queue: string, jobId: JobId): DlqEntry | null;
|
|
21
|
+
removeAllFromDlq(queue: string, jobId: JobId): DlqEntry[];
|
|
21
22
|
getAutoRetryEntries(queue: string, now?: number): DlqEntry[];
|
|
22
23
|
getExpiredEntries(queue: string, now?: number): DlqEntry[];
|
|
23
24
|
purgeExpired(queue: string, now?: number): number;
|
|
@@ -56,6 +56,9 @@ export class ShardDlq extends ShardDependencies {
|
|
|
56
56
|
removeFromDlq(queue, jobId) {
|
|
57
57
|
return this.dlqManager.remove(queue, jobId);
|
|
58
58
|
}
|
|
59
|
+
removeAllFromDlq(queue, jobId) {
|
|
60
|
+
return this.dlqManager.removeAll(queue, jobId);
|
|
61
|
+
}
|
|
59
62
|
getAutoRetryEntries(queue, now = Date.now()) {
|
|
60
63
|
return this.dlqManager.getAutoRetryEntries(queue, now);
|
|
61
64
|
}
|
|
@@ -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;
|
|
@@ -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 | 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);
|
|
@@ -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)
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { jobId } from '../../../domain/types/job';
|
|
2
2
|
import { mapCloudCommandJob } from './jobMapper';
|
|
3
|
+
function pageInteger(value, fallback) {
|
|
4
|
+
if (value === undefined || !Number.isFinite(value))
|
|
5
|
+
return fallback;
|
|
6
|
+
return Math.min(Number.MAX_SAFE_INTEGER, Math.max(0, Math.floor(value)));
|
|
7
|
+
}
|
|
3
8
|
export const JOB_COMMANDS = {
|
|
4
|
-
'job:cancel': async (
|
|
5
|
-
const ok = await
|
|
9
|
+
'job:cancel': async (adapter, command) => {
|
|
10
|
+
const ok = await adapter.cancel(jobId(command.jobId ?? ''));
|
|
6
11
|
return { cancelled: ok };
|
|
7
12
|
},
|
|
8
|
-
'job:promote': async (
|
|
9
|
-
const ok = await
|
|
13
|
+
'job:promote': async (adapter, command) => {
|
|
14
|
+
const ok = await adapter.promote(jobId(command.jobId ?? ''));
|
|
10
15
|
return { promoted: ok };
|
|
11
16
|
},
|
|
12
|
-
'job:push': async (
|
|
13
|
-
const job = await
|
|
17
|
+
'job:push': async (adapter, command) => {
|
|
18
|
+
const job = await adapter.push(command.queue ?? '', {
|
|
14
19
|
name: command.name ?? 'default',
|
|
15
20
|
data: command.data ?? {},
|
|
16
21
|
priority: command.priority,
|
|
@@ -18,80 +23,83 @@ export const JOB_COMMANDS = {
|
|
|
18
23
|
});
|
|
19
24
|
return { jobId: String(job.id), queue: command.queue };
|
|
20
25
|
},
|
|
21
|
-
'job:priority': async (
|
|
22
|
-
const ok = await
|
|
26
|
+
'job:priority': async (adapter, command) => {
|
|
27
|
+
const ok = await adapter.changePriority(jobId(command.jobId ?? ''), command.priority ?? 0);
|
|
23
28
|
return { changed: ok };
|
|
24
29
|
},
|
|
25
|
-
'job:discard': async (
|
|
26
|
-
const ok = await
|
|
30
|
+
'job:discard': async (adapter, command) => {
|
|
31
|
+
const ok = await adapter.discard(jobId(command.jobId ?? ''));
|
|
27
32
|
return { discarded: ok };
|
|
28
33
|
},
|
|
29
|
-
'job:delay': async (
|
|
30
|
-
await
|
|
34
|
+
'job:delay': async (adapter, command) => {
|
|
35
|
+
await adapter.changeDelay(jobId(command.jobId ?? ''), command.delay ?? 0);
|
|
31
36
|
return { delayed: true };
|
|
32
37
|
},
|
|
33
|
-
'job:updateData': async (
|
|
34
|
-
const ok = await
|
|
38
|
+
'job:updateData': async (adapter, command) => {
|
|
39
|
+
const ok = await adapter.updateData(jobId(command.jobId ?? ''), command.data);
|
|
35
40
|
return { updated: ok };
|
|
36
41
|
},
|
|
37
|
-
'job:clearLogs': (
|
|
38
|
-
|
|
42
|
+
'job:clearLogs': async (adapter, command) => {
|
|
43
|
+
await adapter.clearLogs(jobId(command.jobId ?? ''), command.keepLogs);
|
|
39
44
|
return { cleared: true };
|
|
40
45
|
},
|
|
41
|
-
'job:retry': (
|
|
46
|
+
'job:retry': async (adapter, command) => {
|
|
42
47
|
if (command.queue) {
|
|
43
|
-
const count =
|
|
48
|
+
const count = await adapter.retryDlq(command.queue, command.jobId ? jobId(command.jobId) : undefined);
|
|
44
49
|
return { retried: count };
|
|
45
50
|
}
|
|
46
51
|
return { retried: 0 };
|
|
47
52
|
},
|
|
48
|
-
'job:logs': (
|
|
49
|
-
logs:
|
|
53
|
+
'job:logs': async (adapter, command) => ({
|
|
54
|
+
logs: await adapter.getLogs(jobId(command.jobId ?? '')),
|
|
50
55
|
}),
|
|
51
|
-
'job:result': (
|
|
52
|
-
result:
|
|
56
|
+
'job:result': async (adapter, command) => ({
|
|
57
|
+
result: await adapter.getResult(jobId(command.jobId ?? '')),
|
|
53
58
|
}),
|
|
54
|
-
'job:list': (
|
|
55
|
-
const limit = command.limit
|
|
56
|
-
const offset = command.offset
|
|
59
|
+
'job:list': async (adapter, command) => {
|
|
60
|
+
const limit = pageInteger(command.limit, 50);
|
|
61
|
+
const offset = pageInteger(command.offset, 0);
|
|
62
|
+
const end = Math.min(Number.MAX_SAFE_INTEGER, offset + limit);
|
|
57
63
|
const states = command.state
|
|
58
64
|
? command.state.split(',')
|
|
59
65
|
: ['waiting', 'active', 'delayed', 'completed', 'failed'];
|
|
60
|
-
const jobs =
|
|
66
|
+
const jobs = await adapter.listJobs(command.queue ?? '', {
|
|
61
67
|
state: states,
|
|
62
68
|
start: offset,
|
|
63
|
-
end
|
|
69
|
+
end,
|
|
64
70
|
});
|
|
71
|
+
const source = await adapter.readSnapshotSource();
|
|
72
|
+
const counts = source.queues.find(({ name }) => name === (command.queue ?? ''))?.counts;
|
|
65
73
|
return {
|
|
66
74
|
jobs: jobs.map(mapCloudCommandJob),
|
|
67
|
-
total:
|
|
75
|
+
total: (counts?.waiting ?? 0) + (counts?.prioritized ?? 0) + (counts?.delayed ?? 0),
|
|
68
76
|
offset,
|
|
69
77
|
limit,
|
|
70
78
|
};
|
|
71
79
|
},
|
|
72
|
-
'job:get': async (
|
|
80
|
+
'job:get': async (adapter, command) => {
|
|
73
81
|
const id = jobId(command.jobId ?? '');
|
|
74
|
-
const job = await
|
|
82
|
+
const job = await adapter.getJob(id);
|
|
75
83
|
if (!job)
|
|
76
84
|
return { job: null };
|
|
77
85
|
return {
|
|
78
86
|
job: {
|
|
79
87
|
...mapCloudCommandJob(job),
|
|
80
|
-
logs:
|
|
81
|
-
result:
|
|
88
|
+
logs: await adapter.getLogs(id),
|
|
89
|
+
result: await adapter.getResult(id),
|
|
82
90
|
},
|
|
83
91
|
};
|
|
84
92
|
},
|
|
85
|
-
'job:listAll': (
|
|
93
|
+
'job:listAll': async (adapter, command) => {
|
|
86
94
|
const limit = command.limit ?? 50;
|
|
87
95
|
const offset = command.offset ?? 0;
|
|
88
96
|
const states = command.state
|
|
89
97
|
? command.state.split(',')
|
|
90
98
|
: ['waiting', 'active', 'delayed', 'completed', 'failed'];
|
|
91
99
|
const allJobs = [];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
const source = await adapter.readSnapshotSource();
|
|
101
|
+
for (const { job, state } of source.jobs) {
|
|
102
|
+
if (states.includes(state))
|
|
95
103
|
allJobs.push(mapCloudCommandJob(job));
|
|
96
104
|
}
|
|
97
105
|
allJobs.sort((a, b) => b.timestamp - a.timestamp);
|
|
@@ -102,10 +110,10 @@ export const JOB_COMMANDS = {
|
|
|
102
110
|
limit,
|
|
103
111
|
};
|
|
104
112
|
},
|
|
105
|
-
'dlq:retry': (
|
|
106
|
-
retried:
|
|
113
|
+
'dlq:retry': async (adapter, command) => ({
|
|
114
|
+
retried: await adapter.retryDlq(command.queue ?? '', command.jobId ? jobId(command.jobId) : undefined),
|
|
107
115
|
}),
|
|
108
|
-
'dlq:purge': (
|
|
109
|
-
purged:
|
|
116
|
+
'dlq:purge': async (adapter, command) => ({
|
|
117
|
+
purged: await adapter.purgeDlq(command.queue ?? ''),
|
|
110
118
|
}),
|
|
111
119
|
};
|