vona-module-a-queue 5.0.34 → 5.0.35
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/dist/index.js +4 -16
- package/dist/service/queue.d.ts +0 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BeanInfo, BeanBase, uuidv4, deepExtend, instanceDesp, beanFullNameFromOnionName, BeanSimple, BeanScopeBase, createBeanDecorator } from 'vona';
|
|
2
2
|
import { __decorate } from 'tslib';
|
|
3
|
-
import { catchError } from '@cabloy/utils';
|
|
4
3
|
import * as Bull from 'bullmq';
|
|
5
4
|
import { Service, Scope } from 'vona-module-a-bean';
|
|
6
5
|
import { getRedisClientKeyPrefix } from 'vona-module-a-redis';
|
|
@@ -79,14 +78,14 @@ let ServiceQueue = class ServiceQueue extends BeanBase {
|
|
|
79
78
|
_worker.worker = new Bull.Worker(queueKey, async job => {
|
|
80
79
|
// concurrency
|
|
81
80
|
if (queueConfig?.concurrency) {
|
|
82
|
-
return await this.
|
|
81
|
+
return await this._performTask(job);
|
|
83
82
|
}
|
|
84
83
|
// redlock
|
|
85
84
|
const info = job.data;
|
|
86
85
|
const queueNameSub = info.options?.queueNameSub;
|
|
87
86
|
const _lockResource = `queue:${queueKey}${queueNameSub ? `#${queueNameSub}` : ''}`;
|
|
88
87
|
return await this.$scope.redlock.service.redlock.lock(_lockResource, async () => {
|
|
89
|
-
return await this.
|
|
88
|
+
return await this._performTask(job);
|
|
90
89
|
}, {
|
|
91
90
|
// instanceName: job.data.instanceName, // need not
|
|
92
91
|
redlock: _worker.redlock,
|
|
@@ -94,14 +93,14 @@ let ServiceQueue = class ServiceQueue extends BeanBase {
|
|
|
94
93
|
});
|
|
95
94
|
}, _workerOptions);
|
|
96
95
|
_worker.worker.on('failed', (_job, err) => {
|
|
97
|
-
this
|
|
96
|
+
this.app.handleError(err);
|
|
98
97
|
});
|
|
99
98
|
_worker.worker.on('error', err => {
|
|
100
99
|
if (err.message && err.message.includes('Missing lock for job')) {
|
|
101
100
|
const workerInner = _worker.worker;
|
|
102
101
|
if (!workerInner.running) {
|
|
103
102
|
_worker.worker.run().catch(err => {
|
|
104
|
-
this
|
|
103
|
+
this.app.handleError(err);
|
|
105
104
|
});
|
|
106
105
|
}
|
|
107
106
|
}
|
|
@@ -240,17 +239,6 @@ let ServiceQueue = class ServiceQueue extends BeanBase {
|
|
|
240
239
|
const instanceName = instanceDesp(info.options?.instanceName);
|
|
241
240
|
return `${instanceName}||${beanFullNameFromOnionName(info.queueName, 'queue')}`;
|
|
242
241
|
}
|
|
243
|
-
async _performTaskWrapper(job) {
|
|
244
|
-
const [res, err] = await catchError(() => {
|
|
245
|
-
return this._performTask(job);
|
|
246
|
-
});
|
|
247
|
-
if (err) {
|
|
248
|
-
await this.app.handleError(err);
|
|
249
|
-
throw err;
|
|
250
|
-
} else {
|
|
251
|
-
return res;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
242
|
async _performTask(job) {
|
|
255
243
|
const info = job.data;
|
|
256
244
|
// queue config
|
package/dist/service/queue.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export declare class ServiceQueue extends BeanBase {
|
|
|
22
22
|
_queuePush<DATA, RESULT>(info: IQueueJobContext<DATA>, isAsync: boolean): Promise<RESULT>;
|
|
23
23
|
_queueEventsReady(queueQueue: IQueueQueue): Promise<void>;
|
|
24
24
|
_combineQueueKey<DATA>(info: IQueueJobContext<DATA>): string;
|
|
25
|
-
_performTaskWrapper<DATA, RESULT>(job: TypeQueueJob<DATA, RESULT>): Promise<unknown>;
|
|
26
25
|
_performTask<DATA, RESULT>(job: TypeQueueJob<DATA, RESULT>): Promise<unknown>;
|
|
27
26
|
getRepeatKey(jobName: string, repeat: Bull.RepeatOptions): string;
|
|
28
27
|
prepareJobInfo<DATA>(queueName: keyof IQueueRecord, data: DATA, options?: IQueuePushOptions): IQueueJobContext<DATA>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-queue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.35",
|
|
5
5
|
"title": "a-queue",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"bullmq": "^5.66.
|
|
44
|
+
"bullmq": "^5.66.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"clean-package": "^2.2.0",
|