@rvoh/psychic-workers 2.0.1 → 2.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.
|
@@ -525,10 +525,20 @@ export class Background {
|
|
|
525
525
|
}
|
|
526
526
|
if (!queueInstance)
|
|
527
527
|
throw new Error(`missing queue: ${jobConfig?.queue?.toString() || 'N/A'}`);
|
|
528
|
+
const jobOptions = {};
|
|
529
|
+
if (delay)
|
|
530
|
+
jobOptions.delay = delay;
|
|
531
|
+
if (delay && jobId) {
|
|
532
|
+
jobOptions.deduplication = {
|
|
533
|
+
id: jobId,
|
|
534
|
+
ttl: delay,
|
|
535
|
+
extend: true,
|
|
536
|
+
replace: true,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
528
539
|
if (groupId && priority) {
|
|
529
540
|
await queueInstance.add(jobType, jobData, {
|
|
530
|
-
|
|
531
|
-
jobId,
|
|
541
|
+
...jobOptions,
|
|
532
542
|
group: {
|
|
533
543
|
...this.groupIdToGroupConfig(groupId),
|
|
534
544
|
priority: this.mapPriorityWordToPriorityNumber(priority),
|
|
@@ -539,8 +549,7 @@ export class Background {
|
|
|
539
549
|
}
|
|
540
550
|
else {
|
|
541
551
|
await queueInstance.add(jobType, jobData, {
|
|
542
|
-
|
|
543
|
-
jobId,
|
|
552
|
+
...jobOptions,
|
|
544
553
|
group: this.groupIdToGroupConfig(groupId),
|
|
545
554
|
priority: this.mapPriorityWordToPriorityNumber(priority),
|
|
546
555
|
// explicitly typing as JobsOptions because Psychic can't be aware of BullMQ Pro options
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import background, { Background } from '../background/index.js';
|
|
2
1
|
import parallelTestSafeQueueName from '../background/helpers/parallelTestSafeQueueName.js';
|
|
2
|
+
import background, { Background } from '../background/index.js';
|
|
3
3
|
const LOCK_TOKEN = 'psychic-test-worker';
|
|
4
4
|
export default class WorkerTestUtils {
|
|
5
5
|
/*
|
|
@@ -46,7 +46,7 @@ export default class WorkerTestUtils {
|
|
|
46
46
|
if (opts.queue && !queues.length)
|
|
47
47
|
throw new Error(`Expected to find queue with name: ${opts.queue}, but none were found by that name. The queue names available are: ${background.queues.map(queue => queue.name).join(', ')}`);
|
|
48
48
|
for (const queue of queues) {
|
|
49
|
-
const jobs =
|
|
49
|
+
const jobs = await queue.getDelayed();
|
|
50
50
|
for (const job of jobs) {
|
|
51
51
|
const data = job.data;
|
|
52
52
|
if (opts.for) {
|
|
@@ -525,10 +525,20 @@ export class Background {
|
|
|
525
525
|
}
|
|
526
526
|
if (!queueInstance)
|
|
527
527
|
throw new Error(`missing queue: ${jobConfig?.queue?.toString() || 'N/A'}`);
|
|
528
|
+
const jobOptions = {};
|
|
529
|
+
if (delay)
|
|
530
|
+
jobOptions.delay = delay;
|
|
531
|
+
if (delay && jobId) {
|
|
532
|
+
jobOptions.deduplication = {
|
|
533
|
+
id: jobId,
|
|
534
|
+
ttl: delay,
|
|
535
|
+
extend: true,
|
|
536
|
+
replace: true,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
528
539
|
if (groupId && priority) {
|
|
529
540
|
await queueInstance.add(jobType, jobData, {
|
|
530
|
-
|
|
531
|
-
jobId,
|
|
541
|
+
...jobOptions,
|
|
532
542
|
group: {
|
|
533
543
|
...this.groupIdToGroupConfig(groupId),
|
|
534
544
|
priority: this.mapPriorityWordToPriorityNumber(priority),
|
|
@@ -539,8 +549,7 @@ export class Background {
|
|
|
539
549
|
}
|
|
540
550
|
else {
|
|
541
551
|
await queueInstance.add(jobType, jobData, {
|
|
542
|
-
|
|
543
|
-
jobId,
|
|
552
|
+
...jobOptions,
|
|
544
553
|
group: this.groupIdToGroupConfig(groupId),
|
|
545
554
|
priority: this.mapPriorityWordToPriorityNumber(priority),
|
|
546
555
|
// explicitly typing as JobsOptions because Psychic can't be aware of BullMQ Pro options
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import background, { Background } from '../background/index.js';
|
|
2
1
|
import parallelTestSafeQueueName from '../background/helpers/parallelTestSafeQueueName.js';
|
|
2
|
+
import background, { Background } from '../background/index.js';
|
|
3
3
|
const LOCK_TOKEN = 'psychic-test-worker';
|
|
4
4
|
export default class WorkerTestUtils {
|
|
5
5
|
/*
|
|
@@ -46,7 +46,7 @@ export default class WorkerTestUtils {
|
|
|
46
46
|
if (opts.queue && !queues.length)
|
|
47
47
|
throw new Error(`Expected to find queue with name: ${opts.queue}, but none were found by that name. The queue names available are: ${background.queues.map(queue => queue.name).join(', ')}`);
|
|
48
48
|
for (const queue of queues) {
|
|
49
|
-
const jobs =
|
|
49
|
+
const jobs = await queue.getDelayed();
|
|
50
50
|
for (const job of jobs) {
|
|
51
51
|
const data = job.data;
|
|
52
52
|
if (opts.for) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@rvoh/psychic-workers",
|
|
4
4
|
"description": "Background job system for Psychic applications",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.3",
|
|
6
6
|
"author": "RVO Health",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@rvoh/dream": "^2.0.0",
|
|
56
56
|
"@rvoh/psychic": "^2.0.0",
|
|
57
|
-
"bullmq": "
|
|
58
|
-
"ioredis": "
|
|
57
|
+
"bullmq": "^5.64.0",
|
|
58
|
+
"ioredis": "^5.8.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@eslint/js": "=9.0.0",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"@types/node": "^22.5.1",
|
|
70
70
|
"@types/pg": "^8",
|
|
71
71
|
"@types/supertest": "^6.0.3",
|
|
72
|
-
"bullmq": "^5.
|
|
72
|
+
"bullmq": "^5.64.0",
|
|
73
73
|
"eslint": "^9.9.1",
|
|
74
74
|
"express": "^4.21.2",
|
|
75
|
-
"ioredis": "^5.
|
|
75
|
+
"ioredis": "^5.8.2",
|
|
76
76
|
"kysely": "^0.28.7",
|
|
77
77
|
"kysely-codegen": "^0.17.0",
|
|
78
78
|
"luxon-jest-matchers": "^0.1.14",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"typedoc": "^0.26.6",
|
|
88
88
|
"typescript": "^5.8.2",
|
|
89
89
|
"typescript-eslint": "=7.18.0",
|
|
90
|
-
"vitest": "^
|
|
90
|
+
"vitest": "^4.0.10"
|
|
91
91
|
},
|
|
92
92
|
"packageManager": "yarn@4.7.0"
|
|
93
|
-
}
|
|
93
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
## 2.0.1
|
|
2
|
-
|
|
3
|
-
bump glob to close dependabot alert
|
|
4
|
-
|
|
5
|
-
## 2.0.0
|
|
6
|
-
|
|
7
|
-
- namespace exports
|
|
8
|
-
- support Dream and Psychic 2.0
|
|
9
|
-
|
|
10
|
-
## 1.4.0
|
|
11
|
-
|
|
12
|
-
- throw an error if attempting to background an entire Dream model
|
|
13
|
-
|
|
14
|
-
## 1.3.0
|
|
15
|
-
|
|
16
|
-
- update for Psychic 1.11.1 and modern Dream
|
|
17
|
-
|
|
18
|
-
## 1.2.0
|
|
19
|
-
|
|
20
|
-
- update for Dream 1.4.0
|