pg-boss 7.1.0 → 7.2.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 CHANGED
@@ -38,6 +38,7 @@ pg-boss relies on [SKIP LOCKED](http://blog.2ndquadrant.com/what-is-select-skip-
38
38
  This will likely cater the most to teams already familiar with the simplicity of relational database semantics and operations (SQL, querying, and backups). It will be especially useful to those already relying on PostgreSQL that want to limit how many systems are required to monitor and support in their architecture.
39
39
 
40
40
  ## Features
41
+ * Exactly-once job delivery
41
42
  * Backpressure-compatible polling workers
42
43
  * Cron scheduling
43
44
  * Pub/sub API for fan-out queue relationships
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-boss",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Queueing jobs in Node.js using PostgreSQL like a boss",
5
5
  "main": "./src/index.js",
6
6
  "engines": {
package/src/manager.js CHANGED
@@ -56,6 +56,7 @@ class Manager extends EventEmitter {
56
56
  this.insertJobsCommand = plans.insertJobs(config.schema)
57
57
  this.completeJobsCommand = plans.completeJobs(config.schema)
58
58
  this.cancelJobsCommand = plans.cancelJobs(config.schema)
59
+ this.resumeJobsCommand = plans.resumeJobs(config.schema)
59
60
  this.failJobsCommand = plans.failJobs(config.schema)
60
61
  this.getJobByIdCommand = plans.getJobById(config.schema)
61
62
  this.getArchivedJobByIdCommand = plans.getArchivedJobById(config.schema)
@@ -67,6 +68,7 @@ class Manager extends EventEmitter {
67
68
  this.functions = [
68
69
  this.complete,
69
70
  this.cancel,
71
+ this.resume,
70
72
  this.fail,
71
73
  this.fetch,
72
74
  this.fetchCompleted,
@@ -541,6 +543,12 @@ class Manager extends EventEmitter {
541
543
  return this.mapCompletionResponse(ids, result)
542
544
  }
543
545
 
546
+ async resume (id) {
547
+ const ids = this.mapCompletionIdArg(id, 'resume')
548
+ const result = await this.db.executeSql(this.resumeJobsCommand, [ids])
549
+ return this.mapCompletionResponse(ids, result)
550
+ }
551
+
544
552
  async deleteQueue (queue, options) {
545
553
  assert(queue, 'Missing queue name argument')
546
554
  const sql = plans.deleteQueue(this.config.schema, options)
package/src/plans.js CHANGED
@@ -26,6 +26,7 @@ module.exports = {
26
26
  fetchNextJob,
27
27
  completeJobs,
28
28
  cancelJobs,
29
+ resumeJobs,
29
30
  failJobs,
30
31
  insertJob,
31
32
  insertJobs,
@@ -497,6 +498,19 @@ function cancelJobs (schema) {
497
498
  `
498
499
  }
499
500
 
501
+ function resumeJobs (schema) {
502
+ return `
503
+ with results as (
504
+ UPDATE ${schema}.job
505
+ SET completedOn = NULL,
506
+ state = '${states.created}'
507
+ WHERE id IN (SELECT UNNEST($1::uuid[]))
508
+ RETURNING 1
509
+ )
510
+ SELECT COUNT(*) from results
511
+ `
512
+ }
513
+
500
514
  function insertJob (schema) {
501
515
  return `
502
516
  INSERT INTO ${schema}.job (
package/types.d.ts CHANGED
@@ -329,6 +329,9 @@ declare class PgBoss extends EventEmitter {
329
329
  cancel(id: string): Promise<void>;
330
330
  cancel(ids: string[]): Promise<void>;
331
331
 
332
+ resume(id: string): Promise<void>;
333
+ resume(ids: string[]): Promise<void>;
334
+
332
335
  complete(id: string): Promise<void>;
333
336
  complete(id: string, data: object): Promise<void>;
334
337
  complete(ids: string[]): Promise<void>;