pg-boss 9.0.1 → 9.0.3
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 +2 -2
- package/package.json +10 -8
- package/src/index.js +1 -2
- package/types.d.ts +24 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@ Queueing jobs in Node.js using PostgreSQL like a boss.
|
|
|
2
2
|
|
|
3
3
|
[](http://www.postgresql.org)
|
|
4
4
|
[](https://badge.fury.io/js/pg-boss)
|
|
5
|
-
|
|
5
|
+

|
|
6
6
|
[](https://coveralls.io/github/timgit/pg-boss?branch=master)
|
|
7
7
|
|
|
8
8
|
```js
|
|
@@ -33,7 +33,7 @@ async function someAsyncJobHandler(job) {
|
|
|
33
33
|
|
|
34
34
|
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.
|
|
35
35
|
|
|
36
|
-
pg-boss relies on [SKIP LOCKED](
|
|
36
|
+
pg-boss relies on [SKIP LOCKED](https://www.2ndquadrant.com/en/blog/what-is-select-skip-locked-for-in-postgresql-9-5/), a feature added to postgres specifically for message queues, in order to resolve record locking challenges inherent with relational databases. This brings the safety of guaranteed atomic commits of a relational database to your asynchronous job processing.
|
|
37
37
|
|
|
38
38
|
This will likely cater the most to teams already familiar with the simplicity of relational database semantics and operations (SQL, querying, and backups). It will be especially useful to those already relying on PostgreSQL that want to limit how many systems are required to monitor and support in their architecture.
|
|
39
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-boss",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"description": "Queueing jobs in Node.js using PostgreSQL like a boss",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"uuid": "^9.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "^
|
|
20
|
-
"coveralls": "^3.1.0",
|
|
19
|
+
"@types/node": "^20.3.3",
|
|
21
20
|
"luxon": "^3.0.1",
|
|
22
21
|
"mocha": "^10.0.0",
|
|
23
22
|
"nyc": "^15.1.0",
|
|
@@ -25,10 +24,7 @@
|
|
|
25
24
|
},
|
|
26
25
|
"scripts": {
|
|
27
26
|
"test": "standard && mocha",
|
|
28
|
-
"cover": "nyc
|
|
29
|
-
"travis-cover": "nyc --reporter=text npm run travis-test",
|
|
30
|
-
"travis-test": "standard && mocha --jobs 0 --exit",
|
|
31
|
-
"forcover": "npm run travis-cover && nyc report --reporter=text-lcov | coveralls",
|
|
27
|
+
"cover": "nyc npm test",
|
|
32
28
|
"export-schema": "node ./scripts/construct.js",
|
|
33
29
|
"export-migration": "node ./scripts/migrate.js",
|
|
34
30
|
"export-rollback": "node ./scripts/rollback.js",
|
|
@@ -47,7 +43,12 @@
|
|
|
47
43
|
"src/**/*.js"
|
|
48
44
|
],
|
|
49
45
|
"sourceMap": false,
|
|
50
|
-
"instrument": true
|
|
46
|
+
"instrument": true,
|
|
47
|
+
"reporter": [
|
|
48
|
+
"lcov",
|
|
49
|
+
"text-summary",
|
|
50
|
+
"text"
|
|
51
|
+
]
|
|
51
52
|
},
|
|
52
53
|
"standard": {
|
|
53
54
|
"globals": [
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
"it",
|
|
56
57
|
"before",
|
|
57
58
|
"after",
|
|
59
|
+
"before",
|
|
58
60
|
"beforeEach",
|
|
59
61
|
"afterEach"
|
|
60
62
|
]
|
package/src/index.js
CHANGED
|
@@ -94,14 +94,13 @@ class PgBoss extends EventEmitter {
|
|
|
94
94
|
return this
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
this.stopped = false
|
|
98
|
-
|
|
99
97
|
if (this.db.isOurs && !this.db.opened) {
|
|
100
98
|
await this.db.open()
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
await this.contractor.start()
|
|
104
102
|
|
|
103
|
+
this.stopped = false
|
|
105
104
|
this.started = true
|
|
106
105
|
|
|
107
106
|
this.manager.start()
|
package/types.d.ts
CHANGED
|
@@ -107,16 +107,23 @@ declare namespace PgBoss {
|
|
|
107
107
|
newJobCheckIntervalSeconds?: number;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
interface
|
|
110
|
+
interface CommonJobFetchOptions {
|
|
111
|
+
includeMetadata?: boolean;
|
|
112
|
+
enforceSingletonQueueActiveLimit?: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
type JobFetchOptions = CommonJobFetchOptions & {
|
|
111
116
|
teamSize?: number;
|
|
112
117
|
teamConcurrency?: number;
|
|
113
118
|
teamRefill?: boolean;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
type BatchJobFetchOptions = CommonJobFetchOptions & {
|
|
122
|
+
batchSize: number;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
type WorkOptions = JobFetchOptions & JobPollingOptions
|
|
126
|
+
type BatchWorkOptions = BatchJobFetchOptions & JobPollingOptions
|
|
120
127
|
|
|
121
128
|
type FetchOptions = {
|
|
122
129
|
includeMetadata?: boolean;
|
|
@@ -124,11 +131,19 @@ declare namespace PgBoss {
|
|
|
124
131
|
} & ConnectionOptions;
|
|
125
132
|
|
|
126
133
|
interface WorkHandler<ReqData> {
|
|
127
|
-
(job: PgBoss.Job<ReqData>): Promise<
|
|
134
|
+
(job: PgBoss.Job<ReqData>): Promise<any>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface BatchWorkHandler<ReqData> {
|
|
138
|
+
(job: PgBoss.Job<ReqData>[]): Promise<any>;
|
|
128
139
|
}
|
|
129
140
|
|
|
130
141
|
interface WorkWithMetadataHandler<ReqData> {
|
|
131
|
-
(job: PgBoss.JobWithMetadata<ReqData>): Promise<
|
|
142
|
+
(job: PgBoss.JobWithMetadata<ReqData>): Promise<any>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface BatchWorkWithMetadataHandler<ReqData> {
|
|
146
|
+
(job: PgBoss.JobWithMetadata<ReqData>[]): Promise<any>;
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
interface Request {
|
|
@@ -302,6 +317,9 @@ declare class PgBoss extends EventEmitter {
|
|
|
302
317
|
work<ReqData>(name: string, options: PgBoss.WorkOptions & { includeMetadata: true }, handler: PgBoss.WorkWithMetadataHandler<ReqData>): Promise<string>;
|
|
303
318
|
work<ReqData>(name: string, options: PgBoss.WorkOptions, handler: PgBoss.WorkHandler<ReqData>): Promise<string>;
|
|
304
319
|
|
|
320
|
+
work<ReqData>(name: string, options: PgBoss.BatchWorkOptions & { includeMetadata: true }, handler: PgBoss.BatchWorkWithMetadataHandler<ReqData>): Promise<string>;
|
|
321
|
+
work<ReqData>(name: string, options: PgBoss.BatchWorkOptions, handler: PgBoss.BatchWorkHandler<ReqData>): Promise<string>;
|
|
322
|
+
|
|
305
323
|
onComplete(name: string, handler: Function): Promise<string>;
|
|
306
324
|
onComplete(name: string, options: PgBoss.WorkOptions, handler: Function): Promise<string>;
|
|
307
325
|
|