vona-module-a-queue 5.0.12 → 5.0.14
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/.metadata/index.d.ts +29 -30
- package/dist/index.js +43 -44
- package/package.json +1 -1
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
/** service: begin */
|
|
2
|
+
export * from '../service/queue.ts';
|
|
3
|
+
import 'vona';
|
|
4
|
+
declare module 'vona-module-a-bean' {
|
|
5
|
+
interface IServiceRecord {
|
|
6
|
+
'a-queue:queue': never;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare module 'vona-module-a-queue' {
|
|
10
|
+
interface ServiceQueue {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
5
13
|
/** service: end */
|
|
6
14
|
/** service: begin */
|
|
7
15
|
import type { ServiceQueue } from '../service/queue.ts';
|
|
16
|
+
export interface IModuleService {
|
|
17
|
+
'queue': ServiceQueue;
|
|
18
|
+
}
|
|
8
19
|
/** service: end */
|
|
9
20
|
/** service: begin */
|
|
10
|
-
/** monkey: end */
|
|
11
|
-
/** scope: begin */
|
|
12
|
-
import { BeanScopeBase } from 'vona';
|
|
13
|
-
import 'vona';
|
|
14
|
-
import 'vona';
|
|
15
21
|
import 'vona';
|
|
22
|
+
declare module 'vona' {
|
|
23
|
+
interface IBeanRecordGeneral {
|
|
24
|
+
'a-queue.service.queue': ServiceQueue;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** service: end */
|
|
28
|
+
/** startup: begin */
|
|
16
29
|
export * from '../bean/startup.loadQueueWorkers.ts';
|
|
30
|
+
import { type IDecoratorStartupOptions } from 'vona-module-a-startup';
|
|
17
31
|
declare module 'vona-module-a-startup' {
|
|
18
32
|
interface IStartupRecord {
|
|
19
33
|
'a-queue:loadQueueWorkers': IDecoratorStartupOptions;
|
|
@@ -23,32 +37,16 @@ declare module 'vona-module-a-queue' {
|
|
|
23
37
|
interface StartupLoadQueueWorkers {
|
|
24
38
|
}
|
|
25
39
|
}
|
|
26
|
-
/**
|
|
40
|
+
/** startup: end */
|
|
27
41
|
/** config: begin */
|
|
28
42
|
export * from '../config/config.ts';
|
|
29
|
-
|
|
30
|
-
interface IServiceRecord {
|
|
31
|
-
'a-queue:queue': never;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
declare module 'vona-module-a-queue' {
|
|
35
|
-
interface ServiceQueue {
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export interface IModuleService {
|
|
39
|
-
queue: ServiceQueue;
|
|
40
|
-
}
|
|
41
|
-
declare module 'vona' {
|
|
42
|
-
interface IBeanRecordGeneral {
|
|
43
|
-
'a-queue.service.queue': ServiceQueue;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
43
|
+
import type { config } from '../config/config.ts';
|
|
46
44
|
/** config: end */
|
|
47
45
|
/** monkey: begin */
|
|
48
46
|
export * from '../monkey.ts';
|
|
49
|
-
/**
|
|
50
|
-
/**
|
|
51
|
-
|
|
47
|
+
/** monkey: end */
|
|
48
|
+
/** scope: begin */
|
|
49
|
+
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig } from 'vona';
|
|
52
50
|
export declare class ScopeModuleAQueue extends BeanScopeBase {
|
|
53
51
|
}
|
|
54
52
|
export interface ScopeModuleAQueue {
|
|
@@ -56,6 +54,7 @@ export interface ScopeModuleAQueue {
|
|
|
56
54
|
config: TypeModuleConfig<typeof config>;
|
|
57
55
|
service: IModuleService;
|
|
58
56
|
}
|
|
57
|
+
import 'vona';
|
|
59
58
|
declare module 'vona' {
|
|
60
59
|
interface IBeanScopeRecord {
|
|
61
60
|
'a-queue': ScopeModuleAQueue;
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,12 @@
|
|
|
1
|
-
import { BeanInfo, BeanBase,
|
|
2
|
-
import { Scope } from 'vona-module-a-bean';
|
|
3
|
-
import { Startup } from 'vona-module-a-startup';
|
|
1
|
+
import { BeanInfo, BeanBase, uuidv4, deepExtend, instanceDesp, beanFullNameFromOnionName, BeanSimple, BeanScopeBase, createBeanDecorator } from 'vona';
|
|
4
2
|
import * as Bull from 'bullmq';
|
|
5
|
-
import { Service } from 'vona-module-a-
|
|
3
|
+
import { Service, Scope } from 'vona-module-a-bean';
|
|
4
|
+
import { Startup } from 'vona-module-a-startup';
|
|
6
5
|
|
|
7
6
|
var _dec$2, _dec2$2, _class$2;
|
|
8
|
-
let
|
|
9
|
-
instance: true,
|
|
10
|
-
after: true
|
|
11
|
-
}), _dec2$2 = BeanInfo({
|
|
12
|
-
module: "a-queue"
|
|
13
|
-
}), _dec$2(_class$2 = _dec2$2(_class$2 = class StartupLoadQueueWorkers extends BeanBase {
|
|
14
|
-
async execute() {
|
|
15
|
-
// load queue workers
|
|
16
|
-
if (!this.app.meta.isTest) {
|
|
17
|
-
this.scope.service.queue.loadQueueWorkers(this.ctx.instanceName);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}) || _class$2) || _class$2);
|
|
21
|
-
|
|
22
|
-
function config(_app) {
|
|
23
|
-
return {
|
|
24
|
-
worker: {
|
|
25
|
-
lockDuration: 30 * 1000,
|
|
26
|
-
maxStalledCount: 1000,
|
|
27
|
-
stalledInterval: 10 * 1000
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const __ThisModule__ = 'a-queue';
|
|
33
|
-
|
|
34
|
-
class Monkey extends BeanSimple {
|
|
35
|
-
async appClose() {
|
|
36
|
-
const scopeSelf = this.bean.scope(__ThisModule__);
|
|
37
|
-
await scopeSelf.service.queue.clearWorkers();
|
|
38
|
-
}
|
|
39
|
-
async appClosed() {
|
|
40
|
-
const scopeSelf = this.bean.scope(__ThisModule__);
|
|
41
|
-
await scopeSelf.service.queue.clearQueues();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var _dec$1, _dec2$1, _class$1;
|
|
46
|
-
let ServiceQueue = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
7
|
+
let ServiceQueue = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
47
8
|
module: "a-queue"
|
|
48
|
-
}), _dec$
|
|
9
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class ServiceQueue extends BeanBase {
|
|
49
10
|
constructor(...args) {
|
|
50
11
|
super(...args);
|
|
51
12
|
this._workers = {};
|
|
@@ -306,8 +267,46 @@ let ServiceQueue = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
|
306
267
|
options
|
|
307
268
|
};
|
|
308
269
|
}
|
|
270
|
+
}) || _class$2) || _class$2);
|
|
271
|
+
|
|
272
|
+
var _dec$1, _dec2$1, _class$1;
|
|
273
|
+
let StartupLoadQueueWorkers = (_dec$1 = Startup({
|
|
274
|
+
instance: true,
|
|
275
|
+
after: true
|
|
276
|
+
}), _dec2$1 = BeanInfo({
|
|
277
|
+
module: "a-queue"
|
|
278
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class StartupLoadQueueWorkers extends BeanBase {
|
|
279
|
+
async execute() {
|
|
280
|
+
// load queue workers
|
|
281
|
+
if (!this.app.meta.isTest) {
|
|
282
|
+
this.scope.service.queue.loadQueueWorkers(this.ctx.instanceName);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
309
285
|
}) || _class$1) || _class$1);
|
|
310
286
|
|
|
287
|
+
function config(_app) {
|
|
288
|
+
return {
|
|
289
|
+
worker: {
|
|
290
|
+
lockDuration: 30 * 1000,
|
|
291
|
+
maxStalledCount: 1000,
|
|
292
|
+
stalledInterval: 10 * 1000
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const __ThisModule__ = 'a-queue';
|
|
298
|
+
|
|
299
|
+
class Monkey extends BeanSimple {
|
|
300
|
+
async appClose() {
|
|
301
|
+
const scopeSelf = this.bean.scope(__ThisModule__);
|
|
302
|
+
await scopeSelf.service.queue.clearWorkers();
|
|
303
|
+
}
|
|
304
|
+
async appClosed() {
|
|
305
|
+
const scopeSelf = this.bean.scope(__ThisModule__);
|
|
306
|
+
await scopeSelf.service.queue.clearQueues();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
311
310
|
var _dec, _dec2, _class;
|
|
312
311
|
let ScopeModuleAQueue = (_dec = Scope(), _dec2 = BeanInfo({
|
|
313
312
|
module: "a-queue"
|