velocious 1.0.532 → 1.0.533
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 +3 -3
- package/build/background-jobs/main.js +1 -2
- package/build/background-jobs/store.js +94 -79
- package/build/background-jobs/types.js +1 -3
- package/build/background-jobs/web/controller.js +0 -1
- package/build/background-jobs/worker.js +2 -7
- package/build/src/background-jobs/main.d.ts.map +1 -1
- package/build/src/background-jobs/main.js +2 -3
- package/build/src/background-jobs/store.d.ts +14 -23
- package/build/src/background-jobs/store.d.ts.map +1 -1
- package/build/src/background-jobs/store.js +83 -84
- package/build/src/background-jobs/types.d.ts +2 -12
- package/build/src/background-jobs/types.d.ts.map +1 -1
- package/build/src/background-jobs/types.js +2 -4
- package/build/src/background-jobs/web/controller.d.ts.map +1 -1
- package/build/src/background-jobs/web/controller.js +1 -2
- package/build/src/background-jobs/worker.d.ts.map +1 -1
- package/build/src/background-jobs/worker.js +3 -10
- package/package.json +1 -1
- package/src/background-jobs/main.js +1 -2
- package/src/background-jobs/store.js +94 -79
- package/src/background-jobs/types.js +1 -3
- package/src/background-jobs/web/controller.js +0 -1
- package/src/background-jobs/worker.js +2 -7
|
@@ -11,6 +11,16 @@ const MIGRATIONS_TABLE = "velocious_internal_migrations"
|
|
|
11
11
|
const MIGRATION_SCOPE = "background_jobs"
|
|
12
12
|
const MIGRATION_VERSION = "20250215000000"
|
|
13
13
|
const EXECUTION_MODE_BACKFILL_MIGRATION_VERSION = "20260607131010"
|
|
14
|
+
// Drops the redundant legacy `forked` boolean column and rewrites pooled rows to
|
|
15
|
+
// persist `execution_mode = "pooled"` directly (retiring the pooled-as-forked
|
|
16
|
+
// handoff-marker workaround), leaving `execution_mode` as the single source of
|
|
17
|
+
// truth for a job's runtime.
|
|
18
|
+
const DROP_FORKED_COLUMN_MIGRATION_VERSION = "20260719000000"
|
|
19
|
+
// Legacy marker prefix used by rows written before this migration: pooled jobs
|
|
20
|
+
// used to persist as `execution_mode = "forked"` plus a `velocious-pooled:*`
|
|
21
|
+
// handoff id. Retained only to detect and convert those rows in the migration.
|
|
22
|
+
const LEGACY_POOLED_HANDOFF_ID_PREFIX = "velocious-pooled:"
|
|
23
|
+
const LEGACY_POOLED_QUEUED_HANDOFF_ID = `${LEGACY_POOLED_HANDOFF_ID_PREFIX}queued`
|
|
14
24
|
const JOBS_TABLE = "background_jobs"
|
|
15
25
|
const CONCURRENCY_TABLE = "background_job_concurrency"
|
|
16
26
|
const DEFAULT_MAX_RETRIES = 10
|
|
@@ -25,18 +35,6 @@ const EXECUTION_MODES = ["inline", "forked", "pooled", "spawned"]
|
|
|
25
35
|
* process — the same isolation as forked without paying a fresh process per job.
|
|
26
36
|
* @type {import("./types.js").BackgroundJobExecutionMode} */
|
|
27
37
|
const DEFAULT_EXECUTION_MODE = "pooled"
|
|
28
|
-
/**
|
|
29
|
-
* Execution mode a legacy `forked = true` row (persisted before the
|
|
30
|
-
* `execution_mode` column existed) backfills to. It must stay `"forked"` so an
|
|
31
|
-
* upgrade never silently reinterprets already-persisted forked jobs as pooled —
|
|
32
|
-
* distinct from {@link DEFAULT_EXECUTION_MODE}, which only governs new enqueues.
|
|
33
|
-
* @type {import("./types.js").BackgroundJobExecutionMode} */
|
|
34
|
-
const LEGACY_FORKED_EXECUTION_MODE = "forked"
|
|
35
|
-
// Pooled jobs persist with the legacy-safe `forked` mode so a pre-pool main can
|
|
36
|
-
// deserialize and run them during a rolling upgrade. Old versions ignore the
|
|
37
|
-
// nullable handoff id on queued rows, making it a backward-compatible marker.
|
|
38
|
-
const POOLED_HANDOFF_ID_PREFIX = "velocious-pooled:"
|
|
39
|
-
const POOLED_QUEUED_HANDOFF_ID = `${POOLED_HANDOFF_ID_PREFIX}queued`
|
|
40
38
|
const DEFAULT_QUEUE = "default"
|
|
41
39
|
// Queue-derived durable concurrency keys are namespaced so they can't collide
|
|
42
40
|
// with explicit caller-supplied concurrencyKeys.
|
|
@@ -154,8 +152,7 @@ export default class BackgroundJobsStore {
|
|
|
154
152
|
id: jobId,
|
|
155
153
|
job_name: jobName,
|
|
156
154
|
args_json: argsJson,
|
|
157
|
-
|
|
158
|
-
execution_mode: executionMode === "pooled" ? LEGACY_FORKED_EXECUTION_MODE : executionMode,
|
|
155
|
+
execution_mode: executionMode,
|
|
159
156
|
queue,
|
|
160
157
|
max_retries: maxRetries,
|
|
161
158
|
attempts: 0,
|
|
@@ -164,7 +161,7 @@ export default class BackgroundJobsStore {
|
|
|
164
161
|
created_at_ms: now,
|
|
165
162
|
concurrency_key: concurrency?.concurrencyKey || null,
|
|
166
163
|
max_concurrency: concurrency?.maxConcurrency || null,
|
|
167
|
-
handoff_id:
|
|
164
|
+
handoff_id: null
|
|
168
165
|
}
|
|
169
166
|
})
|
|
170
167
|
})
|
|
@@ -175,7 +172,6 @@ export default class BackgroundJobsStore {
|
|
|
175
172
|
/**
|
|
176
173
|
* Runs next available job.
|
|
177
174
|
* @param {object} [args] - Options.
|
|
178
|
-
* @param {boolean} [args.forked] - Compatibility filter for non-inline vs inline jobs.
|
|
179
175
|
* @param {import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]} [args.executionMode] - Execution mode or modes to match.
|
|
180
176
|
* @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Next job.
|
|
181
177
|
*/
|
|
@@ -186,7 +182,6 @@ export default class BackgroundJobsStore {
|
|
|
186
182
|
return await this._nextQueuedJob({
|
|
187
183
|
db,
|
|
188
184
|
scheduledAtOperator: "<=",
|
|
189
|
-
forked: args.forked,
|
|
190
185
|
executionMode: args.executionMode
|
|
191
186
|
})
|
|
192
187
|
})
|
|
@@ -213,11 +208,10 @@ export default class BackgroundJobsStore {
|
|
|
213
208
|
* @param {object} args - Options.
|
|
214
209
|
* @param {import("../database/drivers/base.js").default} args.db - Database connection.
|
|
215
210
|
* @param {"<=" | ">"} args.scheduledAtOperator - Scheduled timestamp operator.
|
|
216
|
-
* @param {boolean} [args.forked] - Compatibility filter for non-inline vs inline jobs.
|
|
217
211
|
* @param {import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]} [args.executionMode] - Execution mode or modes to match.
|
|
218
212
|
* @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Next matching queued job.
|
|
219
213
|
*/
|
|
220
|
-
async _nextQueuedJob({db, scheduledAtOperator,
|
|
214
|
+
async _nextQueuedJob({db, scheduledAtOperator, executionMode}) {
|
|
221
215
|
const now = Date.now()
|
|
222
216
|
let query = db
|
|
223
217
|
.newQuery()
|
|
@@ -236,9 +230,6 @@ export default class BackgroundJobsStore {
|
|
|
236
230
|
)
|
|
237
231
|
}
|
|
238
232
|
|
|
239
|
-
if (typeof forked === "boolean") {
|
|
240
|
-
query = query.where({forked})
|
|
241
|
-
}
|
|
242
233
|
if (executionMode) query = this._whereExecutionMode({db, executionMode, query})
|
|
243
234
|
|
|
244
235
|
if (scheduledAtOperator === "<=") {
|
|
@@ -420,9 +411,7 @@ export default class BackgroundJobsStore {
|
|
|
420
411
|
const queuedJob = await this._getJobRowById(db, jobId)
|
|
421
412
|
if (!queuedJob || queuedJob.status !== "queued") return null
|
|
422
413
|
if (queuedJob.concurrencyKey && !(await this._reserveConcurrency(db, queuedJob.concurrencyKey))) return null
|
|
423
|
-
const handoffId =
|
|
424
|
-
? `${POOLED_HANDOFF_ID_PREFIX}${randomUUID()}`
|
|
425
|
-
: randomUUID()
|
|
414
|
+
const handoffId = randomUUID()
|
|
426
415
|
|
|
427
416
|
const affectedRows = await this._updateAffectedRows(db, {
|
|
428
417
|
tableName: JOBS_TABLE,
|
|
@@ -496,7 +485,7 @@ export default class BackgroundJobsStore {
|
|
|
496
485
|
status: "queued",
|
|
497
486
|
scheduled_at_ms: Date.now(),
|
|
498
487
|
handed_off_at_ms: null,
|
|
499
|
-
handoff_id:
|
|
488
|
+
handoff_id: null,
|
|
500
489
|
worker_id: null
|
|
501
490
|
},
|
|
502
491
|
conditions: {handoff_id: handoffId, id: jobId, status: "handed_off"}
|
|
@@ -842,7 +831,6 @@ export default class BackgroundJobsStore {
|
|
|
842
831
|
table.string("id", {primaryKey: true})
|
|
843
832
|
table.string("job_name", {null: false, index: true})
|
|
844
833
|
table.text("args_json", {null: false})
|
|
845
|
-
table.boolean("forked", {null: false})
|
|
846
834
|
table.string("execution_mode", {null: false})
|
|
847
835
|
table.string("queue", {null: true, index: true})
|
|
848
836
|
table.integer("max_retries", {null: false})
|
|
@@ -916,6 +904,7 @@ export default class BackgroundJobsStore {
|
|
|
916
904
|
}
|
|
917
905
|
|
|
918
906
|
await this._backfillExecutionModesOnce(db)
|
|
907
|
+
await this._dropForkedColumnOnce(db)
|
|
919
908
|
|
|
920
909
|
const lockName = `${MIGRATION_SCOPE}:concurrency_columns`
|
|
921
910
|
const acquired = await db.acquireAdvisoryLock(lockName)
|
|
@@ -1001,12 +990,20 @@ export default class BackgroundJobsStore {
|
|
|
1001
990
|
try {
|
|
1002
991
|
if (await this._hasMigration(db, migrationVersion)) return
|
|
1003
992
|
|
|
993
|
+
// A table created after the `forked` column was dropped has nothing to
|
|
994
|
+
// backfill from; record the migration so it is not re-attempted.
|
|
995
|
+
db.clearSchemaCache()
|
|
996
|
+
if (!(await (await db.getTableByNameOrFail(JOBS_TABLE)).getColumnByName("forked"))) {
|
|
997
|
+
await this._recordMigration(db, migrationVersion)
|
|
998
|
+
return
|
|
999
|
+
}
|
|
1000
|
+
|
|
1004
1001
|
const tableNameSql = db.quoteTable(JOBS_TABLE)
|
|
1005
1002
|
const forkedColumnSql = db.quoteColumn("forked")
|
|
1006
1003
|
const executionModeColumnSql = db.quoteColumn("execution_mode")
|
|
1007
1004
|
|
|
1008
1005
|
await db.query(
|
|
1009
|
-
`UPDATE ${tableNameSql} SET ${executionModeColumnSql} = ${db.quote(
|
|
1006
|
+
`UPDATE ${tableNameSql} SET ${executionModeColumnSql} = ${db.quote("forked")} ` +
|
|
1010
1007
|
`WHERE ${forkedColumnSql} = ${db.quote(true)} AND ${executionModeColumnSql} IS NULL`
|
|
1011
1008
|
)
|
|
1012
1009
|
await db.query(
|
|
@@ -1020,6 +1017,60 @@ export default class BackgroundJobsStore {
|
|
|
1020
1017
|
}
|
|
1021
1018
|
}
|
|
1022
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* Rewrites pre-existing pooled rows (persisted as `execution_mode = "forked"`
|
|
1022
|
+
* plus a `velocious-pooled:*` handoff marker) to `execution_mode = "pooled"`,
|
|
1023
|
+
* clears the queued marker, then drops the now-redundant `forked` column so
|
|
1024
|
+
* `execution_mode` is the single source of truth. Runs once, guarded by the
|
|
1025
|
+
* migration ledger and a per-key advisory lock; a fresh table (created without
|
|
1026
|
+
* the column) short-circuits.
|
|
1027
|
+
* @param {import("../database/drivers/base.js").default} db - Database connection.
|
|
1028
|
+
* @returns {Promise<void>} - Resolves when complete.
|
|
1029
|
+
*/
|
|
1030
|
+
async _dropForkedColumnOnce(db) {
|
|
1031
|
+
const migrationVersion = DROP_FORKED_COLUMN_MIGRATION_VERSION
|
|
1032
|
+
const migrationKey = this._migrationKey(migrationVersion)
|
|
1033
|
+
|
|
1034
|
+
if (await this._hasMigration(db, migrationVersion)) return
|
|
1035
|
+
|
|
1036
|
+
await db.acquireAdvisoryLock(migrationKey)
|
|
1037
|
+
|
|
1038
|
+
try {
|
|
1039
|
+
if (await this._hasMigration(db, migrationVersion)) return
|
|
1040
|
+
|
|
1041
|
+
db.clearSchemaCache()
|
|
1042
|
+
|
|
1043
|
+
if (await (await db.getTableByNameOrFail(JOBS_TABLE)).getColumnByName("forked")) {
|
|
1044
|
+
const tableNameSql = db.quoteTable(JOBS_TABLE)
|
|
1045
|
+
const executionModeColumnSql = db.quoteColumn("execution_mode")
|
|
1046
|
+
const handoffIdColumnSql = db.quoteColumn("handoff_id")
|
|
1047
|
+
|
|
1048
|
+
// Pooled rows used to persist as execution_mode "forked" + a pooled handoff
|
|
1049
|
+
// marker; recover their real mode before the marker is cleared.
|
|
1050
|
+
await db.query(
|
|
1051
|
+
`UPDATE ${tableNameSql} SET ${executionModeColumnSql} = ${db.quote("pooled")} ` +
|
|
1052
|
+
`WHERE ${executionModeColumnSql} = ${db.quote("forked")} ` +
|
|
1053
|
+
`AND ${handoffIdColumnSql} LIKE ${db.quote(`${LEGACY_POOLED_HANDOFF_ID_PREFIX}%`)}`
|
|
1054
|
+
)
|
|
1055
|
+
// The queued-pooled marker was a sentinel, not a real lease; clear it.
|
|
1056
|
+
await db.query(
|
|
1057
|
+
`UPDATE ${tableNameSql} SET ${handoffIdColumnSql} = NULL ` +
|
|
1058
|
+
`WHERE ${handoffIdColumnSql} = ${db.quote(LEGACY_POOLED_QUEUED_HANDOFF_ID)}`
|
|
1059
|
+
)
|
|
1060
|
+
|
|
1061
|
+
const dropForked = new TableData(JOBS_TABLE)
|
|
1062
|
+
dropForked.addColumn("forked", {dropColumn: true})
|
|
1063
|
+
for (const sql of await db.alterTableSQLs(dropForked)) await db.query(sql)
|
|
1064
|
+
|
|
1065
|
+
db.clearSchemaCache()
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
await this._recordMigration(db, migrationVersion)
|
|
1069
|
+
} finally {
|
|
1070
|
+
await db.releaseAdvisoryLock(migrationKey)
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1023
1074
|
/**
|
|
1024
1075
|
* Runs record migration.
|
|
1025
1076
|
* @param {import("../database/drivers/base.js").default} db - Database connection.
|
|
@@ -1097,7 +1148,6 @@ export default class BackgroundJobsStore {
|
|
|
1097
1148
|
scheduledAt,
|
|
1098
1149
|
shouldRetry
|
|
1099
1150
|
})
|
|
1100
|
-
if (shouldRetry && job.executionMode === "pooled") update.handoff_id = POOLED_QUEUED_HANDOFF_ID
|
|
1101
1151
|
|
|
1102
1152
|
const affectedRows = await this._updateAffectedRows(db, {
|
|
1103
1153
|
tableName: JOBS_TABLE,
|
|
@@ -1206,18 +1256,17 @@ export default class BackgroundJobsStore {
|
|
|
1206
1256
|
* @returns {import("./types.js").BackgroundJobRow} - Normalized job row.
|
|
1207
1257
|
*/
|
|
1208
1258
|
_normalizeJobRow(row) {
|
|
1209
|
-
const persistedExecutionMode = row.execution_mode ? String(row.execution_mode) : null
|
|
1210
1259
|
const handoffId = row.handoff_id ? String(row.handoff_id) : null
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1260
|
+
// `execution_mode` is the single source of truth for a job's runtime and is
|
|
1261
|
+
// written on every enqueue; the drop-forked migration backfills any pre-existing
|
|
1262
|
+
// rows before the legacy `forked` column is removed.
|
|
1263
|
+
const executionMode = row.execution_mode ? this._normalizeExecutionModeName(String(row.execution_mode)) : DEFAULT_EXECUTION_MODE
|
|
1214
1264
|
|
|
1215
1265
|
return {
|
|
1216
1266
|
id: String(row.id),
|
|
1217
1267
|
jobName: String(row.job_name),
|
|
1218
1268
|
args: this._parseArgs(row.args_json),
|
|
1219
1269
|
executionMode,
|
|
1220
|
-
forked: executionMode !== "inline",
|
|
1221
1270
|
queue: row.queue ? String(row.queue) : DEFAULT_QUEUE,
|
|
1222
1271
|
status: row.status ? String(row.status) : "queued",
|
|
1223
1272
|
attempts: this._normalizeNumber(row.attempts),
|
|
@@ -1501,19 +1550,6 @@ export default class BackgroundJobsStore {
|
|
|
1501
1550
|
return numeric
|
|
1502
1551
|
}
|
|
1503
1552
|
|
|
1504
|
-
/**
|
|
1505
|
-
* Runs normalize boolean.
|
|
1506
|
-
* @param {?} value - Input value.
|
|
1507
|
-
* @returns {boolean} - Normalized boolean.
|
|
1508
|
-
*/
|
|
1509
|
-
_normalizeBoolean(value) {
|
|
1510
|
-
if (value === null || value === undefined) return false
|
|
1511
|
-
if (typeof value === "boolean") return value
|
|
1512
|
-
if (typeof value === "number") return value !== 0
|
|
1513
|
-
|
|
1514
|
-
return value === "true"
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
1553
|
/**
|
|
1518
1554
|
* Runs normalize execution mode.
|
|
1519
1555
|
* @param {import("./types.js").BackgroundJobOptions} [options] - Job options.
|
|
@@ -1525,11 +1561,14 @@ export default class BackgroundJobsStore {
|
|
|
1525
1561
|
if (executionMode) {
|
|
1526
1562
|
return this._normalizeExecutionModeName(executionMode)
|
|
1527
1563
|
}
|
|
1528
|
-
|
|
1529
|
-
//
|
|
1530
|
-
//
|
|
1531
|
-
|
|
1532
|
-
|
|
1564
|
+
|
|
1565
|
+
// The `forked` option alias was removed. Reject it loudly instead of silently
|
|
1566
|
+
// defaulting to pooled, which would turn an explicitly inline (`forked: false`)
|
|
1567
|
+
// or one-shot forked (`forked: true`) job into a pooled child-runner job — a
|
|
1568
|
+
// silent semantic change for any not-yet-migrated caller.
|
|
1569
|
+
if (options && "forked" in options) {
|
|
1570
|
+
throw new Error("The background job `forked` option was removed; pass `executionMode` (\"inline\", \"forked\", \"pooled\", or \"spawned\") instead")
|
|
1571
|
+
}
|
|
1533
1572
|
|
|
1534
1573
|
return DEFAULT_EXECUTION_MODE
|
|
1535
1574
|
}
|
|
@@ -1548,20 +1587,8 @@ export default class BackgroundJobsStore {
|
|
|
1548
1587
|
}
|
|
1549
1588
|
|
|
1550
1589
|
/**
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
* @param {string} args.executionMode - Persisted legacy execution mode.
|
|
1554
|
-
* @param {string | null} args.handoffId - Persisted handoff id or pooled marker.
|
|
1555
|
-
* @returns {import("./types.js").BackgroundJobExecutionMode} - Runtime execution mode.
|
|
1556
|
-
*/
|
|
1557
|
-
_normalizePersistedExecutionMode({executionMode, handoffId}) {
|
|
1558
|
-
if (executionMode === LEGACY_FORKED_EXECUTION_MODE && handoffId?.startsWith(POOLED_HANDOFF_ID_PREFIX)) return "pooled"
|
|
1559
|
-
|
|
1560
|
-
return this._normalizeExecutionModeName(executionMode)
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* Filters persisted legacy-safe execution modes.
|
|
1590
|
+
* Filters queued jobs by one or more execution modes against the
|
|
1591
|
+
* `execution_mode` column (the single source of truth).
|
|
1565
1592
|
* @param {object} args - Options.
|
|
1566
1593
|
* @param {import("../database/drivers/base.js").default} args.db - Database connection.
|
|
1567
1594
|
* @param {import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]} args.executionMode - Runtime modes.
|
|
@@ -1570,20 +1597,8 @@ export default class BackgroundJobsStore {
|
|
|
1570
1597
|
*/
|
|
1571
1598
|
_whereExecutionMode({db, executionMode, query}) {
|
|
1572
1599
|
const executionModes = Array.isArray(executionMode) ? executionMode : [executionMode]
|
|
1573
|
-
/** @type {string[]} */
|
|
1574
|
-
const conditions = []
|
|
1575
1600
|
const executionModeColumn = db.quoteColumn("execution_mode")
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
for (const mode of executionModes) {
|
|
1579
|
-
if (mode === "pooled") {
|
|
1580
|
-
conditions.push(`(${executionModeColumn} = ${db.quote(LEGACY_FORKED_EXECUTION_MODE)} AND ${handoffIdColumn} = ${db.quote(POOLED_QUEUED_HANDOFF_ID)})`)
|
|
1581
|
-
} else if (mode === LEGACY_FORKED_EXECUTION_MODE) {
|
|
1582
|
-
conditions.push(`(${executionModeColumn} = ${db.quote(mode)} AND (${handoffIdColumn} IS NULL OR ${handoffIdColumn} <> ${db.quote(POOLED_QUEUED_HANDOFF_ID)}))`)
|
|
1583
|
-
} else {
|
|
1584
|
-
conditions.push(`${executionModeColumn} = ${db.quote(mode)}`)
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1601
|
+
const conditions = executionModes.map((mode) => `${executionModeColumn} = ${db.quote(mode)}`)
|
|
1587
1602
|
|
|
1588
1603
|
return query.where(`(${conditions.join(" OR ")})`)
|
|
1589
1604
|
}
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {object} BackgroundJobOptions
|
|
13
|
-
* @property {BackgroundJobExecutionMode} [executionMode] - How the job should run. Defaults to `"pooled"` (a warm, reused local runner process). `"forked"` runs the job in a fresh `child_process.fork()` child, `"spawned"` in a detached CLI runner, and `"inline"` inside the worker process.
|
|
14
|
-
* @property {boolean} [forked] - Compatibility alias: `false` maps to `"inline"` and `true` maps to `"forked"`. Omitting both `forked` and `executionMode` uses the default `"pooled"` mode.
|
|
13
|
+
* @property {BackgroundJobExecutionMode} [executionMode] - How the job should run. Defaults to `"pooled"` (a warm, reused local runner process). `"forked"` runs the job in a fresh `child_process.fork()` child, `"spawned"` in a detached CLI runner, and `"inline"` inside the worker process. Omit to use the default `"pooled"` mode.
|
|
15
14
|
* @property {number} [maxRetries] - Max retries for a failed job before it is marked failed.
|
|
16
15
|
* @property {string} [queue] - Queue name. Defaults to `"default"`. When the queue has a configured cap in `backgroundJobs.queues`, that cap is enforced cluster-wide.
|
|
17
16
|
* @property {string} [concurrencyKey] - Opaque non-empty key used to share a concurrency cap. Overrides any queue-derived cap.
|
|
@@ -35,7 +34,6 @@
|
|
|
35
34
|
* @property {string} jobName - Job class name.
|
|
36
35
|
* @property {Array<?>} args - Serialized job arguments.
|
|
37
36
|
* @property {BackgroundJobExecutionMode} executionMode - How the job should run.
|
|
38
|
-
* @property {boolean} forked - Compatibility flag; true for non-inline execution.
|
|
39
37
|
* @property {string} queue - Queue name (defaults to `"default"`).
|
|
40
38
|
* @property {string} status - Current job status.
|
|
41
39
|
* @property {number | null} attempts - Failure attempts count.
|
|
@@ -196,7 +196,6 @@ export default class VelociousBackgroundJobsWebController extends Controller {
|
|
|
196
196
|
createdAtMs: job.createdAtMs,
|
|
197
197
|
executionMode: job.executionMode,
|
|
198
198
|
failedAtMs: job.failedAtMs,
|
|
199
|
-
forked: job.forked,
|
|
200
199
|
handedOffAtMs: job.handedOffAtMs,
|
|
201
200
|
id: job.id,
|
|
202
201
|
jobName: job.jobName,
|
|
@@ -480,14 +480,9 @@ export default class BackgroundJobsWorker {
|
|
|
480
480
|
* @returns {import("./types.js").BackgroundJobExecutionMode} - Execution mode.
|
|
481
481
|
*/
|
|
482
482
|
_executionModeForPayload(payload) {
|
|
483
|
-
const
|
|
484
|
-
const executionMode = options.executionMode
|
|
483
|
+
const executionMode = payload.options?.executionMode
|
|
485
484
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (options.forked === false) return "inline"
|
|
489
|
-
if (options.forked === true) return "forked"
|
|
490
|
-
return "pooled"
|
|
485
|
+
return executionMode ? this._normalizeExecutionMode(executionMode) : "pooled"
|
|
491
486
|
}
|
|
492
487
|
|
|
493
488
|
/**
|