pg-boss 10.2.0 → 10.3.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/package.json +3 -3
- package/src/manager.js +10 -0
- package/src/plans.js +16 -0
- package/types.d.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-boss",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "Queueing jobs in Postgres from Node.js like a boss",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"cron-parser": "^4.9.0",
|
|
11
|
-
"pg": "^8.
|
|
11
|
+
"pg": "^8.16.0",
|
|
12
12
|
"serialize-error": "^8.1.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/node": "^20.17.
|
|
15
|
+
"@types/node": "^20.17.57",
|
|
16
16
|
"luxon": "^3.6.1",
|
|
17
17
|
"mocha": "^10.8.2",
|
|
18
18
|
"nyc": "^17.1.0",
|
package/src/manager.js
CHANGED
|
@@ -50,6 +50,7 @@ class Manager extends EventEmitter {
|
|
|
50
50
|
this.cancelJobsCommand = plans.cancelJobs(config.schema)
|
|
51
51
|
this.resumeJobsCommand = plans.resumeJobs(config.schema)
|
|
52
52
|
this.deleteJobsCommand = plans.deleteJobs(config.schema)
|
|
53
|
+
this.retryJobsCommand = plans.retryJobs(config.schema)
|
|
53
54
|
this.failJobsByIdCommand = plans.failJobsById(config.schema)
|
|
54
55
|
this.getJobByIdCommand = plans.getJobById(config.schema)
|
|
55
56
|
this.getArchivedJobByIdCommand = plans.getArchivedJobById(config.schema)
|
|
@@ -69,6 +70,7 @@ class Manager extends EventEmitter {
|
|
|
69
70
|
this.complete,
|
|
70
71
|
this.cancel,
|
|
71
72
|
this.resume,
|
|
73
|
+
this.retry,
|
|
72
74
|
this.deleteJob,
|
|
73
75
|
this.fail,
|
|
74
76
|
this.fetch,
|
|
@@ -516,6 +518,14 @@ class Manager extends EventEmitter {
|
|
|
516
518
|
return this.mapCommandResponse(ids, result)
|
|
517
519
|
}
|
|
518
520
|
|
|
521
|
+
async retry (name, id, options = {}) {
|
|
522
|
+
Attorney.assertQueueName(name)
|
|
523
|
+
const db = options.db || this.db
|
|
524
|
+
const ids = this.mapCompletionIdArg(id, 'resume')
|
|
525
|
+
const result = await db.executeSql(this.retryJobsCommand, [name, ids])
|
|
526
|
+
return this.mapCommandResponse(ids, result)
|
|
527
|
+
}
|
|
528
|
+
|
|
519
529
|
async createQueue (name, options = {}) {
|
|
520
530
|
name = name || options.name
|
|
521
531
|
|
package/src/plans.js
CHANGED
|
@@ -29,6 +29,7 @@ module.exports = {
|
|
|
29
29
|
cancelJobs,
|
|
30
30
|
resumeJobs,
|
|
31
31
|
deleteJobs,
|
|
32
|
+
retryJobs,
|
|
32
33
|
failJobsById,
|
|
33
34
|
failJobsByTimeout,
|
|
34
35
|
insertJob,
|
|
@@ -733,6 +734,21 @@ function deleteJobs (schema) {
|
|
|
733
734
|
`
|
|
734
735
|
}
|
|
735
736
|
|
|
737
|
+
function retryJobs (schema) {
|
|
738
|
+
return `
|
|
739
|
+
with results as (
|
|
740
|
+
UPDATE ${schema}.job
|
|
741
|
+
SET state = '${JOB_STATES.retry}',
|
|
742
|
+
retry_limit = retry_limit + 1
|
|
743
|
+
WHERE name = $1
|
|
744
|
+
AND id IN (SELECT UNNEST($2::uuid[]))
|
|
745
|
+
AND state = '${JOB_STATES.failed}'
|
|
746
|
+
RETURNING 1
|
|
747
|
+
)
|
|
748
|
+
SELECT COUNT(*) from results
|
|
749
|
+
`
|
|
750
|
+
}
|
|
751
|
+
|
|
736
752
|
function insertJob (schema) {
|
|
737
753
|
return `
|
|
738
754
|
INSERT INTO ${schema}.job (
|
package/types.d.ts
CHANGED
|
@@ -334,6 +334,9 @@ declare class PgBoss extends EventEmitter {
|
|
|
334
334
|
resume(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
335
335
|
resume(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
336
336
|
|
|
337
|
+
retry(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
338
|
+
retry(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
339
|
+
|
|
337
340
|
deleteJob(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
338
341
|
deleteJob(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
339
342
|
|