pg-boss 8.1.0 → 8.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 +1 -1
- package/package.json +3 -3
- package/src/index.js +1 -3
- package/src/manager.js +4 -8
- package/src/timekeeper.js +1 -2
- package/types.d.ts +19 -19
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ CREATE EXTENSION pgcrypto;
|
|
|
88
88
|
|
|
89
89
|
If you use a different database name, username or password, or want to run the test suite against a database that is running on a remote machine then you will need to edit the `test/config.json` file with the appropriate connection values.
|
|
90
90
|
|
|
91
|
-
You can then run the linter and test suite using
|
|
91
|
+
You can then run the linter and test suite using
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
94
|
npm test
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-boss",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.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()
|
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')
|
package/types.d.ts
CHANGED
|
@@ -48,14 +48,14 @@ declare namespace PgBoss {
|
|
|
48
48
|
|
|
49
49
|
type ConstructorOptions =
|
|
50
50
|
DatabaseOptions
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
& QueueOptions
|
|
52
|
+
& SchedulingOptions
|
|
53
|
+
& MaintenanceOptions
|
|
54
|
+
& ExpirationOptions
|
|
55
|
+
& RetentionOptions
|
|
56
|
+
& RetryOptions
|
|
57
|
+
& JobPollingOptions
|
|
58
|
+
& CompletionOptions
|
|
59
59
|
|
|
60
60
|
interface CompletionOptions {
|
|
61
61
|
onComplete?: boolean;
|
|
@@ -341,22 +341,22 @@ declare class PgBoss extends EventEmitter {
|
|
|
341
341
|
fetchCompleted<T>(name: string, batchSize: number, options: PgBoss.FetchOptions & { includeMetadata: true }): Promise<PgBoss.JobWithMetadata<T>[] | null>;
|
|
342
342
|
fetchCompleted<T>(name: string, batchSize: number, options: PgBoss.FetchOptions): Promise<PgBoss.Job<T>[] | null>;
|
|
343
343
|
|
|
344
|
-
cancel(id: string, options
|
|
345
|
-
cancel(ids: string[], options
|
|
344
|
+
cancel(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
345
|
+
cancel(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
346
346
|
|
|
347
|
-
resume(id: string, options
|
|
348
|
-
resume(ids: string[], options
|
|
347
|
+
resume(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
348
|
+
resume(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
349
349
|
|
|
350
|
-
complete(id: string, options
|
|
351
|
-
complete(id: string, data: object, options
|
|
352
|
-
complete(ids: string[], options
|
|
350
|
+
complete(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
351
|
+
complete(id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
352
|
+
complete(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
353
353
|
|
|
354
|
-
fail(id: string, options
|
|
355
|
-
fail(id: string, data: object, options
|
|
356
|
-
fail(ids: string[], options
|
|
354
|
+
fail(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
355
|
+
fail(id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
356
|
+
fail(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
357
357
|
|
|
358
358
|
getQueueSize(name: string, options?: object): Promise<number>;
|
|
359
|
-
getJobById(id: string, options
|
|
359
|
+
getJobById(id: string, options?: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata | null>;
|
|
360
360
|
|
|
361
361
|
deleteQueue(name: string): Promise<void>;
|
|
362
362
|
deleteAllQueues(): Promise<void>;
|