@pgpm/jobs 0.15.2 → 0.15.4

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/Makefile CHANGED
@@ -1,5 +1,5 @@
1
1
  EXTENSION = pgpm-jobs
2
- DATA = sql/pgpm-jobs--0.14.0.sql
2
+ DATA = sql/pgpm-jobs--0.15.3.sql
3
3
 
4
4
  PG_CONFIG = pg_config
5
5
  PGXS := $(shell $(PG_CONFIG) --pgxs)
package/README.md CHANGED
@@ -290,6 +290,7 @@ Executes a scheduled job.
290
290
 
291
291
  ## Dependencies
292
292
 
293
+ - PGPM roles (anonymous, authenticated, administrator)
293
294
  - `@pgpm/verify`: Verification utilities
294
295
 
295
296
  ## Testing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/jobs",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "description": "Core job system for background task processing in PostgreSQL",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
@@ -21,10 +21,10 @@
21
21
  "test:watch": "jest --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@pgpm/verify": "0.15.2"
24
+ "@pgpm/verify": "0.15.4"
25
25
  },
26
26
  "devDependencies": {
27
- "pgpm": "^1.0.0"
27
+ "pgpm": "^1.2.2"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
@@ -34,5 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/constructive-io/pgpm-modules/issues"
36
36
  },
37
- "gitHead": "92a241bab64c7b20e85e55a7bd314089907fabba"
37
+ "gitHead": "aad0dbef0336d6c18d027120ef9addc418822edd"
38
38
  }
package/pgpm-jobs.control CHANGED
@@ -1,6 +1,6 @@
1
1
  # pgpm-jobs extension
2
2
  comment = 'pgpm-jobs extension'
3
- default_version = '0.14.0'
3
+ default_version = '0.15.3'
4
4
  module_pathname = '$libdir/pgpm-jobs'
5
5
  requires = 'plpgsql,uuid-ossp,pgcrypto,pgpm-verify'
6
6
  relocatable = false
@@ -1,16 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`scheduled jobs schedule jobs 1`] = `
4
- {
5
- "attempts": null,
6
- "id": null,
7
- "key": null,
8
- "last_error": null,
9
- "locked_at": null,
10
- "locked_by": null,
11
- "max_attempts": null,
12
- "payload": null,
13
- "priority": null,
14
- "task_identifier": null,
15
- }
16
- `;
@@ -1,139 +0,0 @@
1
- import { getConnections, PgTestClient } from 'pgsql-test';
2
-
3
- let pg: PgTestClient;
4
- let teardown: () => Promise<void>;
5
-
6
- const objs: Record<string, any> = {};
7
-
8
- describe('scheduled jobs', () => {
9
- beforeAll(async () => {
10
- ({ pg, teardown } = await getConnections());
11
- });
12
-
13
- beforeEach(async () => {
14
- await pg.beforeEach();
15
- });
16
-
17
- afterEach(async () => {
18
- await pg.afterEach();
19
- });
20
-
21
- afterAll(async () => {
22
- await teardown();
23
- });
24
-
25
- it('schedule jobs by cron', async () => {
26
- const result = await pg.one(
27
- `INSERT INTO app_jobs.scheduled_jobs (task_identifier, schedule_info)
28
- VALUES ($1, $2)
29
- RETURNING *`,
30
- [
31
- 'my_job',
32
- {
33
- hour: Array.from({ length: 23 }, (_: unknown, i: number) => i),
34
- minute: [0, 15, 30, 45],
35
- dayOfWeek: Array.from({ length: 6 }, (_: unknown, i: number) => i),
36
- },
37
- ]
38
- );
39
- objs.scheduled1 = result;
40
- });
41
-
42
- it('schedule jobs by rule', async () => {
43
- const start = new Date(Date.now() + 10000);
44
- const end = new Date(start.getTime() + 180000);
45
-
46
- const result = await pg.one(
47
- `INSERT INTO app_jobs.scheduled_jobs (task_identifier, payload, schedule_info)
48
- VALUES ($1, $2, $3)
49
- RETURNING *`,
50
- [
51
- 'my_job',
52
- { just: 'run it' },
53
- { start, end, rule: '*/1 * * * *' }
54
- ]
55
- );
56
- objs.scheduled2 = result;
57
- });
58
-
59
- it('schedule jobs', async () => {
60
- const [result] = await pg.any(
61
- `SELECT * FROM app_jobs.run_scheduled_job($1)`,
62
- [objs.scheduled2.id]
63
- );
64
-
65
- const { queue_name, run_at, created_at, updated_at, ...obj } = result;
66
- expect(obj).toMatchSnapshot();
67
- });
68
-
69
- it('schedule jobs with keys', async () => {
70
- const start = new Date(Date.now() + 10000);
71
- const end = new Date(start.getTime() + 180000);
72
-
73
- const [result] = await pg.any(
74
- `SELECT * FROM app_jobs.add_scheduled_job(
75
- identifier := $1::text,
76
- payload := $2::json,
77
- schedule_info := $3::json,
78
- job_key := $4::text,
79
- queue_name := $5::text,
80
- max_attempts := $6::integer,
81
- priority := $7::integer
82
- )`,
83
- [
84
- 'my_job',
85
- { just: 'run it' },
86
- { start, end, rule: '*/1 * * * *' },
87
- 'new_key',
88
- null,
89
- 25,
90
- 0
91
- ]
92
- );
93
-
94
- const {
95
- queue_name,
96
- run_at,
97
- created_at,
98
- updated_at,
99
- schedule_info: sch,
100
- start: s1,
101
- end: d1,
102
- ...obj
103
- } = result;
104
-
105
- const [result2] = await pg.any(
106
- `SELECT * FROM app_jobs.add_scheduled_job(
107
- identifier := $1,
108
- payload := $2,
109
- schedule_info := $3,
110
- job_key := $4,
111
- queue_name := $5,
112
- max_attempts := $6,
113
- priority := $7
114
- )`,
115
- [
116
- 'my_job',
117
- { just: 'run it' },
118
- { start, end, rule: '*/1 * * * *' },
119
- 'new_key',
120
- null,
121
- 25,
122
- 0
123
- ]
124
- );
125
-
126
- const {
127
- queue_name: qn,
128
- created_at: ca,
129
- updated_at: ua,
130
- schedule_info: sch2,
131
- start: s,
132
- end: e,
133
- ...obj2
134
- } = result2;
135
-
136
- console.log('First insert:', obj);
137
- console.log('Duplicate insert (job_key conflict):', obj2);
138
- });
139
- });