vona-module-a-queue 5.0.33 → 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 +24 -31
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BeanInfo, BeanBase, uuidv4, deepExtend, instanceDesp, beanFullNameFromOnionName, BeanSimple, BeanScopeBase, createBeanDecorator } from 'vona';
|
|
2
|
+
import { __decorate } from 'tslib';
|
|
2
3
|
import * as Bull from 'bullmq';
|
|
3
4
|
import { Service, Scope } from 'vona-module-a-bean';
|
|
4
5
|
import { getRedisClientKeyPrefix } from 'vona-module-a-redis';
|
|
5
6
|
import { Startup } from 'vona-module-a-startup';
|
|
6
7
|
import { Hmr } from 'vona-module-a-hmr';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
10
|
-
module: "a-queue"
|
|
11
|
-
}), _dec$3(_class$3 = _dec2$3(_class$3 = class ServiceQueue extends BeanBase {
|
|
9
|
+
let ServiceQueue = class ServiceQueue extends BeanBase {
|
|
12
10
|
constructor(...args) {
|
|
13
11
|
super(...args);
|
|
14
12
|
this._workers = {};
|
|
@@ -19,7 +17,6 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
19
17
|
if (!info.options?.dbInfo) throw new Error('should specify the options.dbInfo');
|
|
20
18
|
this._queuePush(info, false);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
// { locale, instanceName, module, queueName,queueNameSub,data }
|
|
24
21
|
pushAsync(info) {
|
|
25
22
|
if (!info.options?.dbInfo) throw new Error('should specify the options.dbInfo');
|
|
@@ -67,12 +64,10 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
67
64
|
const workerOptions = queueConfig?.options?.worker;
|
|
68
65
|
const redlockOptions = queueConfig?.options?.redlock;
|
|
69
66
|
const _lockTTL = redlockOptions?.lockTTL ?? this.$scope.redlock.config.lockTTL;
|
|
70
|
-
|
|
71
67
|
// redlock
|
|
72
68
|
if (!queueConfig?.concurrency) {
|
|
73
69
|
_worker.redlock = this.$scope.redlock.service.redlock.create(redlockOptions);
|
|
74
70
|
}
|
|
75
|
-
|
|
76
71
|
// create work
|
|
77
72
|
const connectionWorker = app.bean.redis.get('queue');
|
|
78
73
|
const _workerOptions = Object.assign({}, this.scope.config.worker, workerOptions, {
|
|
@@ -98,19 +93,18 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
98
93
|
});
|
|
99
94
|
}, _workerOptions);
|
|
100
95
|
_worker.worker.on('failed', (_job, err) => {
|
|
101
|
-
this
|
|
96
|
+
this.app.handleError(err);
|
|
102
97
|
});
|
|
103
98
|
_worker.worker.on('error', err => {
|
|
104
99
|
if (err.message && err.message.includes('Missing lock for job')) {
|
|
105
100
|
const workerInner = _worker.worker;
|
|
106
101
|
if (!workerInner.running) {
|
|
107
102
|
_worker.worker.run().catch(err => {
|
|
108
|
-
this
|
|
103
|
+
this.app.handleError(err);
|
|
109
104
|
});
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
});
|
|
113
|
-
|
|
114
108
|
// ok
|
|
115
109
|
return _worker;
|
|
116
110
|
}
|
|
@@ -124,7 +118,6 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
124
118
|
const queueConfig = app.bean.onion.queue.getOnionOptions(info.queueName);
|
|
125
119
|
// queueConfig.options: queue/worker/job/limiter
|
|
126
120
|
const queueOptions = queueConfig?.options?.queue;
|
|
127
|
-
|
|
128
121
|
// create queue
|
|
129
122
|
const connectionQueue = app.bean.redis.get('queue');
|
|
130
123
|
const _queueOptions = Object.assign({}, queueOptions, {
|
|
@@ -134,7 +127,6 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
134
127
|
_queue.config = queueConfig;
|
|
135
128
|
_queue.options = _queueOptions;
|
|
136
129
|
_queue.queue = new Bull.Queue(queueKey, _queueOptions);
|
|
137
|
-
|
|
138
130
|
// create events
|
|
139
131
|
const connectionEvents = app.bean.redis.get('queue');
|
|
140
132
|
const _queueEventsOptions = {
|
|
@@ -155,7 +147,6 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
155
147
|
}) => {
|
|
156
148
|
this._callCallback(jobId, failedReason, undefined);
|
|
157
149
|
});
|
|
158
|
-
|
|
159
150
|
// ok
|
|
160
151
|
return _queue;
|
|
161
152
|
}
|
|
@@ -283,31 +274,34 @@ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
|
283
274
|
options
|
|
284
275
|
};
|
|
285
276
|
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
var _dec$2, _dec2$2, _class$2;
|
|
289
|
-
let StartupLoadQueueWorkers = (_dec$2 = Startup({
|
|
290
|
-
instance: true,
|
|
291
|
-
after: true
|
|
292
|
-
}), _dec2$2 = BeanInfo({
|
|
277
|
+
};
|
|
278
|
+
ServiceQueue = __decorate([Service(), BeanInfo({
|
|
293
279
|
module: "a-queue"
|
|
294
|
-
}),
|
|
280
|
+
})], ServiceQueue);
|
|
281
|
+
|
|
282
|
+
let StartupLoadQueueWorkers = class StartupLoadQueueWorkers extends BeanBase {
|
|
295
283
|
async execute() {
|
|
296
284
|
// load queue workers
|
|
297
285
|
if (!this.app.meta.isTest) {
|
|
298
286
|
this.scope.service.queue.loadQueueWorkers(this.ctx.instanceName);
|
|
299
287
|
}
|
|
300
288
|
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
289
|
+
};
|
|
290
|
+
StartupLoadQueueWorkers = __decorate([Startup({
|
|
291
|
+
instance: true,
|
|
292
|
+
after: true
|
|
293
|
+
}), BeanInfo({
|
|
305
294
|
module: "a-queue"
|
|
306
|
-
}),
|
|
295
|
+
})], StartupLoadQueueWorkers);
|
|
296
|
+
|
|
297
|
+
let HmrQueue = class HmrQueue extends BeanBase {
|
|
307
298
|
async reload(_beanOptions) {
|
|
308
299
|
this.app.bean.worker.reload();
|
|
309
300
|
}
|
|
310
|
-
}
|
|
301
|
+
};
|
|
302
|
+
HmrQueue = __decorate([Hmr(), BeanInfo({
|
|
303
|
+
module: "a-queue"
|
|
304
|
+
})], HmrQueue);
|
|
311
305
|
|
|
312
306
|
function config(_app) {
|
|
313
307
|
return {
|
|
@@ -332,11 +326,10 @@ class Monkey extends BeanSimple {
|
|
|
332
326
|
}
|
|
333
327
|
}
|
|
334
328
|
|
|
335
|
-
|
|
336
|
-
|
|
329
|
+
let ScopeModuleAQueue = class ScopeModuleAQueue extends BeanScopeBase {};
|
|
330
|
+
ScopeModuleAQueue = __decorate([Scope(), BeanInfo({
|
|
337
331
|
module: "a-queue"
|
|
338
|
-
}),
|
|
339
|
-
|
|
332
|
+
})], ScopeModuleAQueue);
|
|
340
333
|
/** scope: end */
|
|
341
334
|
|
|
342
335
|
class BeanQueueBase extends BeanBase {
|
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",
|