pg-boss 8.1.1 → 8.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/index.js +6 -4
- package/src/manager.js +4 -8
- package/src/timekeeper.js +1 -2
- package/types.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-boss",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Queueing jobs in Node.js using PostgreSQL like a boss",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"cron-parser": "^4.0.0",
|
|
11
11
|
"delay": "^5.0.0",
|
|
12
12
|
"lodash.debounce": "^4.0.8",
|
|
13
|
-
"p-map": "^
|
|
13
|
+
"p-map": "^4.0.0",
|
|
14
14
|
"pg": "^8.5.1",
|
|
15
|
-
"serialize-error": "^
|
|
15
|
+
"serialize-error": "^8.1.0",
|
|
16
16
|
"uuid": "^9.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
package/src/index.js
CHANGED
|
@@ -90,8 +90,6 @@ class PgBoss extends EventEmitter {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
async start () {
|
|
93
|
-
const { serializeError } = await import('serialize-error')
|
|
94
|
-
|
|
95
93
|
if (!this.stopped) {
|
|
96
94
|
return this
|
|
97
95
|
}
|
|
@@ -106,7 +104,7 @@ class PgBoss extends EventEmitter {
|
|
|
106
104
|
|
|
107
105
|
this.started = true
|
|
108
106
|
|
|
109
|
-
this.manager.start(
|
|
107
|
+
this.manager.start()
|
|
110
108
|
|
|
111
109
|
if (!this.config.noSupervisor) {
|
|
112
110
|
await this.boss.supervise()
|
|
@@ -128,7 +126,7 @@ class PgBoss extends EventEmitter {
|
|
|
128
126
|
this.emit(events.stopped)
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
let { graceful = true, timeout = 30000 } = options
|
|
129
|
+
let { destroy = false, graceful = true, timeout = 30000 } = options
|
|
132
130
|
|
|
133
131
|
timeout = Math.max(timeout, 1000)
|
|
134
132
|
|
|
@@ -141,6 +139,10 @@ class PgBoss extends EventEmitter {
|
|
|
141
139
|
this.stopped = true
|
|
142
140
|
this.stoppingOn = null
|
|
143
141
|
|
|
142
|
+
if (this.db.isOurs && this.db.opened && destroy) {
|
|
143
|
+
await this.db.close()
|
|
144
|
+
}
|
|
145
|
+
|
|
144
146
|
this.emit(events.stopped)
|
|
145
147
|
}
|
|
146
148
|
|
package/src/manager.js
CHANGED
|
@@ -3,9 +3,10 @@ const EventEmitter = require('events')
|
|
|
3
3
|
const delay = require('delay')
|
|
4
4
|
const uuid = require('uuid')
|
|
5
5
|
const debounce = require('lodash.debounce')
|
|
6
|
-
|
|
6
|
+
const { serializeError: stringify } = require('serialize-error')
|
|
7
7
|
const Attorney = require('./attorney')
|
|
8
8
|
const Worker = require('./worker')
|
|
9
|
+
const pMap = require('p-map')
|
|
9
10
|
|
|
10
11
|
const { QUEUES: BOSS_QUEUES } = require('./boss')
|
|
11
12
|
const { QUEUES: TIMEKEEPER_QUEUES } = require('./timekeeper')
|
|
@@ -44,8 +45,6 @@ class Manager extends EventEmitter {
|
|
|
44
45
|
constructor (db, config) {
|
|
45
46
|
super()
|
|
46
47
|
|
|
47
|
-
this.stringify = null
|
|
48
|
-
|
|
49
48
|
this.config = config
|
|
50
49
|
this.db = db
|
|
51
50
|
|
|
@@ -98,8 +97,7 @@ class Manager extends EventEmitter {
|
|
|
98
97
|
this.emitWipThrottled = debounce(() => this.emit(events.wip, this.getWipData()), WIP_EVENT_INTERVAL, WIP_DEBOUNCE_OPTIONS)
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
start (
|
|
102
|
-
this.stringify = stringify
|
|
100
|
+
start () {
|
|
103
101
|
this.stopping = false
|
|
104
102
|
}
|
|
105
103
|
|
|
@@ -213,8 +211,6 @@ class Manager extends EventEmitter {
|
|
|
213
211
|
const fetch = () => this.fetch(name, batchSize || (teamSize - queueSize), { includeMetadata })
|
|
214
212
|
|
|
215
213
|
const onFetch = async (jobs) => {
|
|
216
|
-
const { default: pMap } = await import('p-map')
|
|
217
|
-
|
|
218
214
|
if (this.config.__test__throw_worker) {
|
|
219
215
|
throw new Error('__test__throw_worker')
|
|
220
216
|
}
|
|
@@ -524,7 +520,7 @@ class Manager extends EventEmitter {
|
|
|
524
520
|
? data
|
|
525
521
|
: { value: data }
|
|
526
522
|
|
|
527
|
-
return
|
|
523
|
+
return stringify(result)
|
|
528
524
|
}
|
|
529
525
|
|
|
530
526
|
mapCompletionResponse (ids, result) {
|
package/src/timekeeper.js
CHANGED
|
@@ -2,6 +2,7 @@ const EventEmitter = require('events')
|
|
|
2
2
|
const plans = require('./plans')
|
|
3
3
|
const cronParser = require('cron-parser')
|
|
4
4
|
const Attorney = require('./attorney')
|
|
5
|
+
const pMap = require('p-map')
|
|
5
6
|
|
|
6
7
|
const queues = {
|
|
7
8
|
CRON: '__pgboss__cron',
|
|
@@ -125,8 +126,6 @@ class Timekeeper extends EventEmitter {
|
|
|
125
126
|
async onCron () {
|
|
126
127
|
if (this.stopped) return
|
|
127
128
|
|
|
128
|
-
const { default: pMap } = await import('p-map')
|
|
129
|
-
|
|
130
129
|
try {
|
|
131
130
|
if (this.config.__test__throw_clock_monitoring) {
|
|
132
131
|
throw new Error('clock monitoring error')
|