pg-boss 10.0.0-beta13 → 10.0.0-beta14
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 +1 -1
- package/src/manager.js +17 -19
- package/src/plans.js +6 -6
package/package.json
CHANGED
package/src/manager.js
CHANGED
|
@@ -60,6 +60,14 @@ class Manager extends EventEmitter {
|
|
|
60
60
|
this.unsubscribeCommand = plans.unsubscribe(config.schema)
|
|
61
61
|
this.getQueuesCommand = plans.getQueues(config.schema)
|
|
62
62
|
this.getQueuesForEventCommand = plans.getQueuesForEvent(config.schema)
|
|
63
|
+
this.getQueueByNameCommand = plans.getQueueByName(config.schema)
|
|
64
|
+
this.deleteQueueRecordsCommand = plans.deleteQueueRecords(config.schema)
|
|
65
|
+
this.insertQueueCommand = plans.insertQueue(config.schema)
|
|
66
|
+
this.updateQueueCommand = plans.updateQueue(config.schema)
|
|
67
|
+
this.createPartitionCommand = plans.createPartition(config.schema)
|
|
68
|
+
this.dropPartitionCommand = plans.dropPartition(config.schema)
|
|
69
|
+
this.clearStorageCommand = plans.clearStorage(config.schema)
|
|
70
|
+
this.purgeQueueCommand = plans.purgeQueue(config.schema)
|
|
63
71
|
|
|
64
72
|
// exported api to index
|
|
65
73
|
this.functions = [
|
|
@@ -564,11 +572,7 @@ class Manager extends EventEmitter {
|
|
|
564
572
|
Attorney.assertQueueName(deadLetter)
|
|
565
573
|
}
|
|
566
574
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
await this.db.executeSql(paritionSql)
|
|
570
|
-
|
|
571
|
-
const sql = plans.insertQueue(this.config.schema)
|
|
575
|
+
await this.db.executeSql(this.createPartitionCommand, [name])
|
|
572
576
|
|
|
573
577
|
const params = [
|
|
574
578
|
name,
|
|
@@ -581,7 +585,7 @@ class Manager extends EventEmitter {
|
|
|
581
585
|
deadLetter
|
|
582
586
|
]
|
|
583
587
|
|
|
584
|
-
await this.db.executeSql(
|
|
588
|
+
await this.db.executeSql(this.insertQueueCommand, params)
|
|
585
589
|
}
|
|
586
590
|
|
|
587
591
|
async getQueues () {
|
|
@@ -605,8 +609,6 @@ class Manager extends EventEmitter {
|
|
|
605
609
|
deadLetter
|
|
606
610
|
} = Attorney.checkQueueArgs(name, options)
|
|
607
611
|
|
|
608
|
-
const sql = plans.updateQueue(this.config.schema)
|
|
609
|
-
|
|
610
612
|
const params = [
|
|
611
613
|
name,
|
|
612
614
|
policy,
|
|
@@ -618,14 +620,13 @@ class Manager extends EventEmitter {
|
|
|
618
620
|
deadLetter
|
|
619
621
|
]
|
|
620
622
|
|
|
621
|
-
await this.db.executeSql(
|
|
623
|
+
await this.db.executeSql(this.updateQueueCommand, params)
|
|
622
624
|
}
|
|
623
625
|
|
|
624
626
|
async getQueue (name) {
|
|
625
627
|
Attorney.assertQueueName(name)
|
|
626
628
|
|
|
627
|
-
const
|
|
628
|
-
const result = await this.db.executeSql(sql, [name])
|
|
629
|
+
const result = await this.db.executeSql(this.getQueueByNameCommand, [name])
|
|
629
630
|
|
|
630
631
|
if (result.rows.length === 0) {
|
|
631
632
|
return null
|
|
@@ -656,24 +657,21 @@ class Manager extends EventEmitter {
|
|
|
656
657
|
async deleteQueue (name) {
|
|
657
658
|
Attorney.assertQueueName(name)
|
|
658
659
|
|
|
659
|
-
const
|
|
660
|
-
const { rows } = await this.db.executeSql(queueSql, [name])
|
|
660
|
+
const { rows } = await this.db.executeSql(this.getQueueByNameCommand, [name])
|
|
661
661
|
|
|
662
662
|
if (rows.length) {
|
|
663
|
-
await this.db.executeSql(
|
|
664
|
-
await this.db.executeSql(
|
|
663
|
+
await this.db.executeSql(this.dropPartitionCommand, [name])
|
|
664
|
+
await this.db.executeSql(this.deleteQueueRecordsCommand, [name])
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
|
|
668
668
|
async purgeQueue (name) {
|
|
669
669
|
Attorney.assertQueueName(name)
|
|
670
|
-
|
|
671
|
-
await this.db.executeSql(sql, [name])
|
|
670
|
+
await this.db.executeSql(this.purgeQueueCommand, [name])
|
|
672
671
|
}
|
|
673
672
|
|
|
674
673
|
async clearStorage () {
|
|
675
|
-
|
|
676
|
-
await this.db.executeSql(sql)
|
|
674
|
+
await this.db.executeSql(this.clearStorageCommand)
|
|
677
675
|
}
|
|
678
676
|
|
|
679
677
|
async getQueueSize (name, options) {
|
package/src/plans.js
CHANGED
|
@@ -216,8 +216,8 @@ const allJobColumns = `${baseJobColumns}, policy, state, priority,
|
|
|
216
216
|
output
|
|
217
217
|
`
|
|
218
218
|
|
|
219
|
-
function createPartition (schema
|
|
220
|
-
return `SELECT ${schema}.create_partition(
|
|
219
|
+
function createPartition (schema) {
|
|
220
|
+
return `SELECT ${schema}.create_partition($1)`
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
function getPartitionFunction (schema) {
|
|
@@ -275,8 +275,8 @@ function dropPartitionFunction (schema) {
|
|
|
275
275
|
`
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
function dropPartition (schema
|
|
279
|
-
return `SELECT ${schema}.drop_partition(
|
|
278
|
+
function dropPartition (schema) {
|
|
279
|
+
return `SELECT ${schema}.drop_partition($1)`
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
function createPrimaryKeyJob (schema) {
|
|
@@ -284,11 +284,11 @@ function createPrimaryKeyJob (schema) {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
function createQueueForeignKeyJob (schema) {
|
|
287
|
-
return `ALTER TABLE ${schema}.job ADD FOREIGN KEY (name) REFERENCES ${schema}.queue (name) ON DELETE RESTRICT`
|
|
287
|
+
return `ALTER TABLE ${schema}.job ADD CONSTRAINT q_fkey FOREIGN KEY (name) REFERENCES ${schema}.queue (name) ON DELETE RESTRICT`
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
function createQueueForeignKeyJobDeadLetter (schema) {
|
|
291
|
-
return `ALTER TABLE ${schema}.job ADD FOREIGN KEY (dead_letter) REFERENCES ${schema}.queue (name) ON DELETE RESTRICT`
|
|
291
|
+
return `ALTER TABLE ${schema}.job ADD CONSTRAINT dlq_fkey FOREIGN KEY (dead_letter) REFERENCES ${schema}.queue (name) ON DELETE RESTRICT`
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
function createPrimaryKeyArchive (schema) {
|