pg-boss 10.0.0-beta10 → 10.0.0-beta12
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/attorney.js +0 -1
- package/src/manager.js +9 -2
- package/src/plans.js +10 -3
- package/types.d.ts +1 -0
package/package.json
CHANGED
package/src/attorney.js
CHANGED
|
@@ -187,7 +187,6 @@ function assertPostgresObjectName (name) {
|
|
|
187
187
|
|
|
188
188
|
function assertQueueName (name) {
|
|
189
189
|
assert(typeof name === 'string', 'Name must be a string')
|
|
190
|
-
assert(name.length <= 50, 'Name cannot exceed 50 characters')
|
|
191
190
|
assert(/[\w-]/.test(name), 'Name can only contain alphanumeric characters, underscores, or hyphens')
|
|
192
191
|
}
|
|
193
192
|
|
package/src/manager.js
CHANGED
|
@@ -58,6 +58,7 @@ class Manager extends EventEmitter {
|
|
|
58
58
|
this.getArchivedJobByIdCommand = plans.getArchivedJobById(config.schema)
|
|
59
59
|
this.subscribeCommand = plans.subscribe(config.schema)
|
|
60
60
|
this.unsubscribeCommand = plans.unsubscribe(config.schema)
|
|
61
|
+
this.getQueuesCommand = plans.getQueues(config.schema)
|
|
61
62
|
this.getQueuesForEventCommand = plans.getQueuesForEvent(config.schema)
|
|
62
63
|
|
|
63
64
|
// exported api to index
|
|
@@ -80,10 +81,11 @@ class Manager extends EventEmitter {
|
|
|
80
81
|
this.sendAfter,
|
|
81
82
|
this.createQueue,
|
|
82
83
|
this.updateQueue,
|
|
83
|
-
this.getQueue,
|
|
84
84
|
this.deleteQueue,
|
|
85
85
|
this.purgeQueue,
|
|
86
86
|
this.getQueueSize,
|
|
87
|
+
this.getQueue,
|
|
88
|
+
this.getQueues,
|
|
87
89
|
this.clearStorage,
|
|
88
90
|
this.getJobById
|
|
89
91
|
]
|
|
@@ -562,7 +564,7 @@ class Manager extends EventEmitter {
|
|
|
562
564
|
|
|
563
565
|
await this.db.executeSql(paritionSql)
|
|
564
566
|
|
|
565
|
-
const sql = plans.
|
|
567
|
+
const sql = plans.insertQueue(this.config.schema)
|
|
566
568
|
|
|
567
569
|
const params = [
|
|
568
570
|
name,
|
|
@@ -578,6 +580,11 @@ class Manager extends EventEmitter {
|
|
|
578
580
|
await this.db.executeSql(sql, params)
|
|
579
581
|
}
|
|
580
582
|
|
|
583
|
+
async getQueues () {
|
|
584
|
+
const { rows } = await this.db.executeSql(this.getQueuesCommand)
|
|
585
|
+
return rows
|
|
586
|
+
}
|
|
587
|
+
|
|
581
588
|
async updateQueue (name, options = {}) {
|
|
582
589
|
assert(name, 'Missing queue name argument')
|
|
583
590
|
|
package/src/plans.js
CHANGED
|
@@ -42,11 +42,12 @@ module.exports = {
|
|
|
42
42
|
archive,
|
|
43
43
|
drop,
|
|
44
44
|
countStates,
|
|
45
|
-
|
|
45
|
+
insertQueue,
|
|
46
46
|
updateQueue,
|
|
47
47
|
createPartition,
|
|
48
48
|
dropPartition,
|
|
49
49
|
deleteQueueRecords,
|
|
50
|
+
getQueues,
|
|
50
51
|
getQueueByName,
|
|
51
52
|
getQueueSize,
|
|
52
53
|
purgeQueue,
|
|
@@ -216,7 +217,7 @@ function dropPartitionFunction (schema) {
|
|
|
216
217
|
RETURNS VOID AS
|
|
217
218
|
$$
|
|
218
219
|
BEGIN
|
|
219
|
-
EXECUTE format('DROP TABLE IF EXISTS
|
|
220
|
+
EXECUTE format('DROP TABLE IF EXISTS ${schema}.%I', ${schema}.get_partition(queue_name));
|
|
220
221
|
END;
|
|
221
222
|
$$
|
|
222
223
|
LANGUAGE plpgsql;
|
|
@@ -232,6 +233,7 @@ function createPrimaryKeyArchive (schema) {
|
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
function createIndexJobPolicyShort (schema) {
|
|
236
|
+
// todo: how to combine these policies with singleton key?
|
|
235
237
|
return `CREATE UNIQUE INDEX job_policy_short ON ${schema}.job (name) WHERE state = '${JOB_STATES.created}' AND policy = '${QUEUE_POLICIES.short}'`
|
|
236
238
|
}
|
|
237
239
|
|
|
@@ -248,6 +250,7 @@ function createIndexJobThrottleOn (schema) {
|
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
function createIndexJobThrottleKey (schema) {
|
|
253
|
+
// how useful is this really?
|
|
251
254
|
return `CREATE UNIQUE INDEX job_throttle_key ON ${schema}.job (name, singleton_key) WHERE state <= '${JOB_STATES.completed}' AND singleton_on IS NULL`
|
|
252
255
|
}
|
|
253
256
|
|
|
@@ -287,7 +290,7 @@ function trySetTimestamp (schema, column) {
|
|
|
287
290
|
`
|
|
288
291
|
}
|
|
289
292
|
|
|
290
|
-
function
|
|
293
|
+
function insertQueue (schema) {
|
|
291
294
|
return `
|
|
292
295
|
INSERT INTO ${schema}.queue (name, policy, retry_limit, retry_delay, retry_backoff, expire_seconds, retention_minutes, dead_letter)
|
|
293
296
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
@@ -307,6 +310,10 @@ function updateQueue (schema) {
|
|
|
307
310
|
`
|
|
308
311
|
}
|
|
309
312
|
|
|
313
|
+
function getQueues (schema) {
|
|
314
|
+
return `SELECT * FROM ${schema}.queue`
|
|
315
|
+
}
|
|
316
|
+
|
|
310
317
|
function getQueueByName (schema) {
|
|
311
318
|
return `SELECT * FROM ${schema}.queue WHERE name = $1`
|
|
312
319
|
}
|
package/types.d.ts
CHANGED
|
@@ -370,6 +370,7 @@ declare class PgBoss extends EventEmitter {
|
|
|
370
370
|
|
|
371
371
|
createQueue(name: string, options?: PgBoss.Queue): Promise<void>;
|
|
372
372
|
getQueue(name: string): Promise<PgBoss.Queue | null>;
|
|
373
|
+
getQueues(): Promise<[PgBoss.Queue]>;
|
|
373
374
|
updateQueue(name: string, options?: PgBoss.QueueUpdateOptions): Promise<void>;
|
|
374
375
|
deleteQueue(name: string): Promise<void>;
|
|
375
376
|
purgeQueue(name: string): Promise<void>;
|