pg-boss 10.0.3 → 10.0.5
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 +6 -0
- package/package.json +1 -1
- package/src/plans.js +11 -1
- package/src/timekeeper.js +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,12 @@ async function readme() {
|
|
|
25
25
|
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`)
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
readme()
|
|
30
|
+
.catch(err => {
|
|
31
|
+
console.log(err)
|
|
32
|
+
process.exit(1)
|
|
33
|
+
})
|
|
28
34
|
```
|
|
29
35
|
|
|
30
36
|
pg-boss is a job queue built in Node.js on top of PostgreSQL in order to provide background processing and reliable asynchronous execution to Node.js applications.
|
package/package.json
CHANGED
package/src/plans.js
CHANGED
|
@@ -226,8 +226,10 @@ function createQueueFunction (schema) {
|
|
|
226
226
|
$$
|
|
227
227
|
DECLARE
|
|
228
228
|
table_name varchar := 'j' || encode(sha224(queue_name::bytea), 'hex');
|
|
229
|
+
queue_created_on timestamptz;
|
|
229
230
|
BEGIN
|
|
230
231
|
|
|
232
|
+
WITH q as (
|
|
231
233
|
INSERT INTO ${schema}.queue (
|
|
232
234
|
name,
|
|
233
235
|
policy,
|
|
@@ -249,7 +251,15 @@ function createQueueFunction (schema) {
|
|
|
249
251
|
(options->>'retentionMinutes')::int,
|
|
250
252
|
options->>'deadLetter',
|
|
251
253
|
table_name
|
|
252
|
-
)
|
|
254
|
+
)
|
|
255
|
+
ON CONFLICT DO NOTHING
|
|
256
|
+
RETURNING created_on
|
|
257
|
+
)
|
|
258
|
+
SELECT created_on into queue_created_on from q;
|
|
259
|
+
|
|
260
|
+
IF queue_created_on IS NULL THEN
|
|
261
|
+
RETURN;
|
|
262
|
+
END IF;
|
|
253
263
|
|
|
254
264
|
EXECUTE format('CREATE TABLE ${schema}.%I (LIKE ${schema}.job INCLUDING DEFAULTS)', table_name);
|
|
255
265
|
|
package/src/timekeeper.js
CHANGED
|
@@ -144,7 +144,7 @@ class Timekeeper extends EventEmitter {
|
|
|
144
144
|
const scheduled = schedules
|
|
145
145
|
.filter(i => this.shouldSendIt(i.cron, i.timezone))
|
|
146
146
|
.map(({ name, data, options }) =>
|
|
147
|
-
({ name: QUEUES.SEND_IT, data: { name, data, options },
|
|
147
|
+
({ name: QUEUES.SEND_IT, data: { name, data, options }, singletonKey: name, singletonSeconds: 60 }))
|
|
148
148
|
|
|
149
149
|
if (scheduled.length > 0 && !this.stopped) {
|
|
150
150
|
await this.manager.insert(scheduled)
|