pg-boss 10.1.3 → 10.1.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 +2 -2
- package/package.json +6 -5
- package/src/migrationStore.js +66 -0
- package/src/plans.js +1 -1
- package/version.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ pg-boss relies on [SKIP LOCKED](https://www.2ndquadrant.com/en/blog/what-is-sele
|
|
|
40
40
|
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.
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
## Summary
|
|
43
|
+
## Summary <!-- {docsify-ignore-all} -->
|
|
44
44
|
* Exactly-once job delivery
|
|
45
45
|
* Create jobs within your existing database transaction
|
|
46
46
|
* Backpressure-compatible polling workers
|
|
@@ -67,7 +67,7 @@ yarn add pg-boss
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
## Documentation
|
|
70
|
-
* [Docs](
|
|
70
|
+
* [Docs](https://timgit.github.io/pg-boss/)
|
|
71
71
|
|
|
72
72
|
## Contributing
|
|
73
73
|
To setup a development environment for this library:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-boss",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.5",
|
|
4
4
|
"description": "Queueing jobs in Postgres from Node.js like a boss",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"cron-parser": "^4.9.0",
|
|
11
|
-
"pg": "^8.
|
|
11
|
+
"pg": "^8.13.0",
|
|
12
12
|
"serialize-error": "^8.1.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/node": "^20.16.
|
|
15
|
+
"@types/node": "^20.16.9",
|
|
16
16
|
"luxon": "^3.5.0",
|
|
17
17
|
"mocha": "^10.7.3",
|
|
18
|
-
"nyc": "^17.
|
|
18
|
+
"nyc": "^17.1.0",
|
|
19
19
|
"standard": "^17.1.2"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"cover": "nyc npm test",
|
|
24
24
|
"tsc": "tsc --noEmit types.d.ts",
|
|
25
25
|
"readme": "node ./test/readme.js",
|
|
26
|
-
"migrate": "node -e 'console.log(require(\"./src\").getMigrationPlans())'"
|
|
26
|
+
"db:migrate": "node -e 'console.log(require(\"./src\").getMigrationPlans())'",
|
|
27
|
+
"db:construct": "node -e 'console.log(require(\"./src\").getConstructionPlans())'"
|
|
27
28
|
},
|
|
28
29
|
"mocha": {
|
|
29
30
|
"timeout": 10000,
|
package/src/migrationStore.js
CHANGED
|
@@ -64,6 +64,72 @@ function migrate (value, version, migrations) {
|
|
|
64
64
|
|
|
65
65
|
function getAll (schema) {
|
|
66
66
|
return [
|
|
67
|
+
{
|
|
68
|
+
release: '10.1.5',
|
|
69
|
+
version: 24,
|
|
70
|
+
previous: 23,
|
|
71
|
+
install: [
|
|
72
|
+
`
|
|
73
|
+
CREATE OR REPLACE FUNCTION ${schema}.create_queue(queue_name text, options json)
|
|
74
|
+
RETURNS VOID AS
|
|
75
|
+
$$
|
|
76
|
+
DECLARE
|
|
77
|
+
table_name varchar := 'j' || encode(sha224(queue_name::bytea), 'hex');
|
|
78
|
+
queue_created_on timestamptz;
|
|
79
|
+
BEGIN
|
|
80
|
+
|
|
81
|
+
WITH q as (
|
|
82
|
+
INSERT INTO ${schema}.queue (
|
|
83
|
+
name,
|
|
84
|
+
policy,
|
|
85
|
+
retry_limit,
|
|
86
|
+
retry_delay,
|
|
87
|
+
retry_backoff,
|
|
88
|
+
expire_seconds,
|
|
89
|
+
retention_minutes,
|
|
90
|
+
dead_letter,
|
|
91
|
+
partition_name
|
|
92
|
+
)
|
|
93
|
+
VALUES (
|
|
94
|
+
queue_name,
|
|
95
|
+
options->>'policy',
|
|
96
|
+
(options->>'retryLimit')::int,
|
|
97
|
+
(options->>'retryDelay')::int,
|
|
98
|
+
(options->>'retryBackoff')::bool,
|
|
99
|
+
(options->>'expireInSeconds')::int,
|
|
100
|
+
(options->>'retentionMinutes')::int,
|
|
101
|
+
options->>'deadLetter',
|
|
102
|
+
table_name
|
|
103
|
+
)
|
|
104
|
+
ON CONFLICT DO NOTHING
|
|
105
|
+
RETURNING created_on
|
|
106
|
+
)
|
|
107
|
+
SELECT created_on into queue_created_on from q;
|
|
108
|
+
|
|
109
|
+
IF queue_created_on IS NULL THEN
|
|
110
|
+
RETURN;
|
|
111
|
+
END IF;
|
|
112
|
+
|
|
113
|
+
EXECUTE format('CREATE TABLE ${schema}.%I (LIKE ${schema}.job INCLUDING DEFAULTS)', table_name);
|
|
114
|
+
|
|
115
|
+
EXECUTE format('ALTER TABLE ${schema}.%1$I ADD PRIMARY KEY (name, id)', table_name);
|
|
116
|
+
EXECUTE format('ALTER TABLE ${schema}.%1$I ADD CONSTRAINT q_fkey FOREIGN KEY (name) REFERENCES ${schema}.queue (name) ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED', table_name);
|
|
117
|
+
EXECUTE format('ALTER TABLE ${schema}.%1$I ADD CONSTRAINT dlq_fkey FOREIGN KEY (dead_letter) REFERENCES ${schema}.queue (name) ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED', table_name);
|
|
118
|
+
EXECUTE format('CREATE UNIQUE INDEX %1$s_i1 ON ${schema}.%1$I (name, COALESCE(singleton_key, '''')) WHERE state = ''created'' AND policy = ''short''', table_name);
|
|
119
|
+
EXECUTE format('CREATE UNIQUE INDEX %1$s_i2 ON ${schema}.%1$I (name, COALESCE(singleton_key, '''')) WHERE state = ''active'' AND policy = ''singleton''', table_name);
|
|
120
|
+
EXECUTE format('CREATE UNIQUE INDEX %1$s_i3 ON ${schema}.%1$I (name, state, COALESCE(singleton_key, '''')) WHERE state <= ''active'' AND policy = ''stately''', table_name);
|
|
121
|
+
EXECUTE format('CREATE UNIQUE INDEX %1$s_i4 ON ${schema}.%1$I (name, singleton_on, COALESCE(singleton_key, '''')) WHERE state <> ''cancelled'' AND singleton_on IS NOT NULL', table_name);
|
|
122
|
+
EXECUTE format('CREATE INDEX %1$s_i5 ON ${schema}.%1$I (name, start_after) INCLUDE (priority, created_on, id) WHERE state < ''active''', table_name);
|
|
123
|
+
|
|
124
|
+
EXECUTE format('ALTER TABLE ${schema}.%I ADD CONSTRAINT cjc CHECK (name=%L)', table_name, queue_name);
|
|
125
|
+
EXECUTE format('ALTER TABLE ${schema}.job ATTACH PARTITION ${schema}.%I FOR VALUES IN (%L)', table_name, queue_name);
|
|
126
|
+
END;
|
|
127
|
+
$$
|
|
128
|
+
LANGUAGE plpgsql
|
|
129
|
+
`
|
|
130
|
+
],
|
|
131
|
+
uninstall: []
|
|
132
|
+
},
|
|
67
133
|
{
|
|
68
134
|
release: '10.1.1',
|
|
69
135
|
version: 23,
|
package/src/plans.js
CHANGED
|
@@ -332,7 +332,7 @@ function createPrimaryKeyArchive (schema) {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
function createIndexJobPolicyShort (schema) {
|
|
335
|
-
return `CREATE UNIQUE INDEX job_i1 ON ${schema}.job (name, COALESCE(singleton_key, '')) WHERE state = '${JOB_STATES.created}' AND policy = '${QUEUE_POLICIES.short}'
|
|
335
|
+
return `CREATE UNIQUE INDEX job_i1 ON ${schema}.job (name, COALESCE(singleton_key, '')) WHERE state = '${JOB_STATES.created}' AND policy = '${QUEUE_POLICIES.short}'`
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
function createIndexJobPolicySingleton (schema) {
|
package/version.json
CHANGED