vona-module-a-queue 5.0.35 → 5.1.1
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/LICENSE +0 -0
- package/dist/.metadata/index.d.ts +1 -0
- package/dist/.metadata/index.d.ts.map +1 -0
- package/dist/.metadata/this.d.ts +1 -0
- package/dist/.metadata/this.d.ts.map +1 -0
- package/dist/bean/hmr.queue.d.ts +1 -0
- package/dist/bean/hmr.queue.d.ts.map +1 -0
- package/dist/bean/startup.loadQueueWorkers.d.ts +1 -0
- package/dist/bean/startup.loadQueueWorkers.d.ts.map +1 -0
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/lib/beanQueueBase.d.ts +2 -1
- package/dist/lib/beanQueueBase.d.ts.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/queue.d.ts +1 -0
- package/dist/lib/queue.d.ts.map +1 -0
- package/dist/monkey.d.ts +1 -0
- package/dist/monkey.d.ts.map +1 -0
- package/dist/service/queue.d.ts +2 -1
- package/dist/service/queue.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/queue.d.ts +1 -0
- package/dist/types/queue.d.ts.map +1 -0
- package/package.json +37 -32
- package/src/.metadata/index.ts +133 -0
- package/src/.metadata/this.ts +2 -0
- package/src/bean/hmr.queue.ts +12 -0
- package/src/bean/startup.loadQueueWorkers.ts +14 -0
- package/src/config/config.ts +12 -0
- package/src/index.ts +3 -0
- package/src/lib/beanQueueBase.ts +21 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/queue.ts +7 -0
- package/src/monkey.ts +17 -0
- package/src/service/queue.ts +309 -0
- package/src/types/index.ts +1 -0
- package/src/types/queue.ts +83 -0
package/LIC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AAI,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/bean/hmr.queue.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.queue.d.ts","sourceRoot":"","sources":["../../src/bean/hmr.queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGhC,qBACa,QAAS,SAAQ,QAAS,YAAW,UAAU;IACpD,MAAM,CAAC,YAAY,EAAE,yBAAyB;CAGrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.loadQueueWorkers.d.ts","sourceRoot":"","sources":["../../src/bean/startup.loadQueueWorkers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGhC,qBACa,uBAAwB,SAAQ,QAAS,YAAW,eAAe;IACxE,OAAO;CAMd"}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,wBAAgB,MAAM,CAAC,IAAI,EAAE,eAAe;YAMnC,IAAI,CAAC,aAAa;EAE1B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as Bull from 'bullmq';
|
|
|
4
4
|
import { Service, Scope } from 'vona-module-a-bean';
|
|
5
5
|
import { getRedisClientKeyPrefix } from 'vona-module-a-redis';
|
|
6
6
|
import { Startup } from 'vona-module-a-startup';
|
|
7
|
-
import { Hmr } from 'vona-module-a-
|
|
7
|
+
import { Hmr } from 'vona-module-a-hmrbase';
|
|
8
8
|
|
|
9
9
|
let ServiceQueue = class ServiceQueue extends BeanBase {
|
|
10
10
|
constructor(...args) {
|
|
@@ -349,3 +349,4 @@ function Queue(options) {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
export { BeanQueueBase, HmrQueue, Monkey, Queue, ScopeModuleAQueue, ServiceQueue, StartupLoadQueueWorkers, config };
|
|
352
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/service/queue.ts","../src/bean/startup.loadQueueWorkers.ts","../src/bean/hmr.queue.ts","../src/config/config.ts","../src/.metadata/this.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/beanQueueBase.ts","../src/lib/queue.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["ServiceQueue","BeanBase","constructor","args","_workers","_queues","_queueCallbacks","push","info","options","dbInfo","Error","_queuePush","pushAsync","loadQueueWorkers","instanceName","queueItem","bean","onion","queue","getOnionsEnabledCached","queueName","name","data","undefined","_ensureWorker","clearWorkers","queueKey","_worker","worker","close","clearQueues","_queue","queueEvents","_getPrefix","getRedisClientKeyPrefix","app","_createWorker","prefix","queueConfig","getOnionOptions","workerOptions","redlockOptions","redlock","_lockTTL","lockTTL","$scope","config","concurrency","service","create","connectionWorker","redis","get","_workerOptions","Object","assign","scope","connection","Bull","Worker","job","_performTask","queueNameSub","_lockResource","lock","on","_job","err","handleError","message","includes","workerInner","running","run","catch","_createQueue","queueOptions","connectionQueue","_queueOptions","Queue","connectionEvents","_queueEventsOptions","queueEventsOptions","QueueEvents","jobId","returnvalue","_callCallback","failedReason","_combineQueueKey","_ensureQueue","getQueue","_getQueue","ctx","_callback","callback","isAsync","jobOptionsBase","queueQueue","jobOptions","uuidv4","jobName","deepExtend","add","Promise","resolve","reject","_queueEventsReady","then","queueEventsReady","waitUntilReady","instanceDesp","beanFullNameFromOnionName","getOnionSlice","executor","newCtx","beanFullName","beanOptions","beanInstance","_getBean","execute","locale","tz","extraData","transaction","getRepeatKey","repeat","endDate","Date","getTime","pattern","suffix","String","every","prepareJobInfo","prepareGeneralInfo","__decorate","Service","__z_BeanInfo","module","StartupLoadQueueWorkers","meta","isTest","Startup","instance","after","HmrQueue","reload","_beanOptions","Hmr","_app","lockDuration","maxStalledCount","stalledInterval","__ThisModule__","Monkey","BeanSimple","appClose","scopeSelf","appClosed","ScopeModuleAQueue","BeanScopeBase","Scope","BeanQueueBase","$onionName","createBeanDecorator"],"mappings":";;;;;;;;AAqBO,IAAMA,YAAY,GAAlB,MAAMA,YAAa,SAAQC,QAAQ,CAAA;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;IAAA,IAAA,CACxCC,QAAQ,GAAgB,EAAE;IAAA,IAAA,CAC1BC,OAAO,GAAiB,EAAE;IAAA,IAAA,CAC1BC,eAAe,GAAoB,EAAE;AAAA,EAAA;EAErCC,IAAIA,CAAOC,IAA4B,EAAA;AACrC,IAAA,IAAI,CAACA,IAAI,CAACC,OAAO,EAAEC,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC;AAC/E,IAAA,IAAI,CAACC,UAAU,CAACJ,IAAI,EAAE,KAAK,CAAC;AAC9B,EAAA;AAEA;EACAK,SAASA,CAAeL,IAA4B,EAAA;AAClD,IAAA,IAAI,CAACA,IAAI,CAACC,OAAO,EAAEC,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,mCAAm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,EAAErJ,YAAY,CAAC;AACtG,EAAA;AACD;;AChBK,SAAUiE,KAAKA,CAACvE,OAAgC,EAAA;AACpD,EAAA,OAAO4J,mBAAmB,CAAC,OAAO,EAAE5J,OAAO,CAAC;AAC9C;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IInstanceRecord } from 'vona';
|
|
2
|
-
import type { IQueuePushOptions } from '../types/queue.ts';
|
|
3
2
|
import { BeanBase } from 'vona';
|
|
3
|
+
import type { IQueuePushOptions } from '../types/queue.ts';
|
|
4
4
|
export declare class BeanQueueBase<DATA = unknown, RESULT = unknown> extends BeanBase {
|
|
5
5
|
pushAsync(data: DATA, options?: IQueuePushOptions): Promise<RESULT>;
|
|
6
6
|
push(data: DATA, options?: IQueuePushOptions): void;
|
|
7
7
|
getQueue(instanceName?: keyof IInstanceRecord): import("bullmq").Queue<any, any, string, any, any, string>;
|
|
8
8
|
}
|
|
9
|
+
//# sourceMappingURL=beanQueueBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beanQueueBase.d.ts","sourceRoot":"","sources":["../../src/lib/beanQueueBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,iBAAiB,EAAgB,MAAM,mBAAmB,CAAC;AAEzE,qBAAa,aAAa,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,CAAE,SAAQ,QAAQ;IACrE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAMzE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAI5C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,eAAe;CAG9C"}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
package/dist/lib/queue.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,cAAc,CAEtE"}
|
package/dist/monkey.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monkey.d.ts","sourceRoot":"","sources":["../src/monkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlC,qBAAa,MAAO,SAAQ,UAAW,YAAW,eAAe,EAAE,gBAAgB;IAC3E,QAAQ;IAKR,SAAS;CAIhB"}
|
package/dist/service/queue.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IInstanceRecord } from 'vona';
|
|
2
|
-
import type { IQueueCallbacks, IQueueJobContext, IQueuePushOptions, IQueueQueue, IQueueQueues, IQueueRecord, IQueueWork, IQueueWorks, TypeQueueJob } from '../types/queue.ts';
|
|
3
2
|
import * as Bull from 'bullmq';
|
|
4
3
|
import { BeanBase } from 'vona';
|
|
4
|
+
import type { IQueueCallbacks, IQueueJobContext, IQueuePushOptions, IQueueQueue, IQueueQueues, IQueueRecord, IQueueWork, IQueueWorks, TypeQueueJob } from '../types/queue.ts';
|
|
5
5
|
export declare class ServiceQueue extends BeanBase {
|
|
6
6
|
_workers: IQueueWorks;
|
|
7
7
|
_queues: IQueueQueues;
|
|
@@ -26,3 +26,4 @@ export declare class ServiceQueue extends BeanBase {
|
|
|
26
26
|
getRepeatKey(jobName: string, repeat: Bull.RepeatOptions): string;
|
|
27
27
|
prepareJobInfo<DATA>(queueName: keyof IQueueRecord, data: DATA, options?: IQueuePushOptions): IQueueJobContext<DATA>;
|
|
28
28
|
}
|
|
29
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/service/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAA+D,MAAM,MAAM,CAAC;AAI7F,OAAO,KAAK,EACV,eAAe,EAEf,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,qBACa,YAAa,SAAQ,QAAQ;IACxC,QAAQ,EAAE,WAAW,CAAM;IAC3B,OAAO,EAAE,YAAY,CAAM;IAC3B,eAAe,EAAE,eAAe,CAAM;IAEtC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAMvC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAKtE,gBAAgB,CAAC,YAAY,CAAC,EAAE,MAAM,eAAe,GAAG,SAAS,GAAG,IAAI;IAalE,YAAY;IAQZ,WAAW;IASjB,UAAU;IAIV,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM;IAsElE,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB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AC,GAAG;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrE,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC;KACxB,CAAC;CACH;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAiB,SAAS;QACxB,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACnC;CACF;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAiB,YAAY;QAC3B,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;KAChC;IAED,UAAiB,gBAAgB;QAC/B,KAAK,EAAE,KAAK,CAAC;KACd;CACF"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-queue",
|
|
3
|
-
"
|
|
4
|
-
"version": "5.0.35",
|
|
5
|
-
"title": "a-queue",
|
|
6
|
-
"vonaModule": {
|
|
7
|
-
"dependencies": {},
|
|
8
|
-
"globalDependencies": {
|
|
9
|
-
"bullmq": true
|
|
10
|
-
},
|
|
11
|
-
"onions": {
|
|
12
|
-
"queue": {
|
|
13
|
-
"optionsGlobalInterfaceName": "IDecoratorQueueOptions",
|
|
14
|
-
"optionsGlobalInterfaceFrom": "vona-module-a-queue",
|
|
15
|
-
"scopeResource": true,
|
|
16
|
-
"boilerplate": "boilerplate"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"capabilities": {
|
|
20
|
-
"monkey": true
|
|
21
|
-
}
|
|
22
|
-
},
|
|
3
|
+
"version": "5.1.1",
|
|
23
4
|
"description": "",
|
|
24
|
-
"author": "",
|
|
25
5
|
"keywords": [
|
|
26
6
|
"Vona Module"
|
|
27
7
|
],
|
|
8
|
+
"author": "",
|
|
9
|
+
"files": [
|
|
10
|
+
"assets",
|
|
11
|
+
"cli",
|
|
12
|
+
"dist",
|
|
13
|
+
"src"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
28
16
|
"exports": {
|
|
29
17
|
".": {
|
|
30
18
|
"types": [
|
|
@@ -35,20 +23,37 @@
|
|
|
35
23
|
},
|
|
36
24
|
"./package.json": "./package.json"
|
|
37
25
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
26
|
+
"scripts": {
|
|
27
|
+
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
28
|
+
"tsc:publish": "npm run clean && vona :bin:buildModule --sourcemap && tsc -p tsconfig.build.json",
|
|
29
|
+
"prepublishOnly": "npm run tsc:publish",
|
|
30
|
+
"prepack": "clean-package",
|
|
31
|
+
"postpack": "clean-package restore && npm run clean"
|
|
32
|
+
},
|
|
43
33
|
"dependencies": {
|
|
44
|
-
"bullmq": "^5.
|
|
34
|
+
"bullmq": "^5.70.1"
|
|
45
35
|
},
|
|
46
36
|
"devDependencies": {
|
|
47
37
|
"clean-package": "^2.2.0",
|
|
48
38
|
"rimraf": "^6.0.1"
|
|
49
39
|
},
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
"title": "a-queue",
|
|
41
|
+
"vonaModule": {
|
|
42
|
+
"dependencies": {},
|
|
43
|
+
"globalDependencies": {
|
|
44
|
+
"bullmq": true
|
|
45
|
+
},
|
|
46
|
+
"onions": {
|
|
47
|
+
"queue": {
|
|
48
|
+
"optionsGlobalInterfaceName": "IDecoratorQueueOptions",
|
|
49
|
+
"optionsGlobalInterfaceFrom": "vona-module-a-queue",
|
|
50
|
+
"scopeResource": true,
|
|
51
|
+
"boilerplate": "boilerplate"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"capabilities": {
|
|
55
|
+
"monkey": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "991189da4443b789fcf77872990b901ccf43bccb"
|
|
59
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// eslint-disable
|
|
2
|
+
/** service: begin */
|
|
3
|
+
export * from '../service/queue.ts';
|
|
4
|
+
|
|
5
|
+
import 'vona-module-a-bean';
|
|
6
|
+
declare module 'vona-module-a-bean' {
|
|
7
|
+
|
|
8
|
+
export interface IServiceRecord {
|
|
9
|
+
'a-queue:queue': never;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
declare module 'vona-module-a-queue' {
|
|
15
|
+
|
|
16
|
+
export interface ServiceQueue {
|
|
17
|
+
/** @internal */
|
|
18
|
+
get scope(): ScopeModuleAQueue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ServiceQueue {
|
|
22
|
+
get $beanFullName(): 'a-queue.service.queue';
|
|
23
|
+
get $onionName(): 'a-queue:queue';
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** service: end */
|
|
28
|
+
/** service: begin */
|
|
29
|
+
import type { ServiceQueue } from '../service/queue.ts';
|
|
30
|
+
export interface IModuleService {
|
|
31
|
+
'queue': ServiceQueue;
|
|
32
|
+
}
|
|
33
|
+
/** service: end */
|
|
34
|
+
/** service: begin */
|
|
35
|
+
|
|
36
|
+
import 'vona';
|
|
37
|
+
declare module 'vona' {
|
|
38
|
+
export interface IBeanRecordGeneral {
|
|
39
|
+
'a-queue.service.queue': ServiceQueue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** service: end */
|
|
43
|
+
/** startup: begin */
|
|
44
|
+
export * from '../bean/startup.loadQueueWorkers.ts';
|
|
45
|
+
|
|
46
|
+
import { type IDecoratorStartupOptions } from 'vona-module-a-startup';
|
|
47
|
+
declare module 'vona-module-a-startup' {
|
|
48
|
+
|
|
49
|
+
export interface IStartupRecord {
|
|
50
|
+
'a-queue:loadQueueWorkers': IDecoratorStartupOptions;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
declare module 'vona-module-a-queue' {
|
|
56
|
+
|
|
57
|
+
export interface StartupLoadQueueWorkers {
|
|
58
|
+
/** @internal */
|
|
59
|
+
get scope(): ScopeModuleAQueue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface StartupLoadQueueWorkers {
|
|
63
|
+
get $beanFullName(): 'a-queue.startup.loadQueueWorkers';
|
|
64
|
+
get $onionName(): 'a-queue:loadQueueWorkers';
|
|
65
|
+
get $onionOptions(): IDecoratorStartupOptions;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** startup: end */
|
|
69
|
+
/** hmr: begin */
|
|
70
|
+
export * from '../bean/hmr.queue.ts';
|
|
71
|
+
|
|
72
|
+
import 'vona';
|
|
73
|
+
declare module 'vona' {
|
|
74
|
+
|
|
75
|
+
export interface IHmrRecord {
|
|
76
|
+
'a-queue:queue': never;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
declare module 'vona-module-a-queue' {
|
|
82
|
+
|
|
83
|
+
export interface HmrQueue {
|
|
84
|
+
/** @internal */
|
|
85
|
+
get scope(): ScopeModuleAQueue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface HmrQueue {
|
|
89
|
+
get $beanFullName(): 'a-queue.hmr.queue';
|
|
90
|
+
get $onionName(): 'a-queue:queue';
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** hmr: end */
|
|
95
|
+
/** config: begin */
|
|
96
|
+
export * from '../config/config.ts';
|
|
97
|
+
import type { config } from '../config/config.ts';
|
|
98
|
+
/** config: end */
|
|
99
|
+
/** monkey: begin */
|
|
100
|
+
export * from '../monkey.ts';
|
|
101
|
+
/** monkey: end */
|
|
102
|
+
/** scope: begin */
|
|
103
|
+
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig } from 'vona';
|
|
104
|
+
import { Scope } from 'vona-module-a-bean';
|
|
105
|
+
|
|
106
|
+
@Scope()
|
|
107
|
+
export class ScopeModuleAQueue extends BeanScopeBase {}
|
|
108
|
+
|
|
109
|
+
export interface ScopeModuleAQueue {
|
|
110
|
+
util: BeanScopeUtil;
|
|
111
|
+
config: TypeModuleConfig<typeof config>;
|
|
112
|
+
service: IModuleService;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
import 'vona';
|
|
116
|
+
declare module 'vona' {
|
|
117
|
+
export interface IBeanScopeRecord {
|
|
118
|
+
'a-queue': ScopeModuleAQueue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface IBeanScopeContainer {
|
|
122
|
+
queue: ScopeModuleAQueue;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface IBeanScopeConfig {
|
|
126
|
+
'a-queue': ReturnType<typeof config>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
/** scope: end */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDecoratorBeanOptionsBase } from 'vona';
|
|
2
|
+
import type { IHmrReload } from 'vona-module-a-hmr';
|
|
3
|
+
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
import { Hmr } from 'vona-module-a-hmrbase';
|
|
6
|
+
|
|
7
|
+
@Hmr()
|
|
8
|
+
export class HmrQueue extends BeanBase implements IHmrReload {
|
|
9
|
+
async reload(_beanOptions: IDecoratorBeanOptionsBase) {
|
|
10
|
+
this.app.bean.worker.reload();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IStartupExecute } from 'vona-module-a-startup';
|
|
2
|
+
|
|
3
|
+
import { BeanBase } from 'vona';
|
|
4
|
+
import { Startup } from 'vona-module-a-startup';
|
|
5
|
+
|
|
6
|
+
@Startup({ instance: true, after: true })
|
|
7
|
+
export class StartupLoadQueueWorkers extends BeanBase implements IStartupExecute {
|
|
8
|
+
async execute() {
|
|
9
|
+
// load queue workers
|
|
10
|
+
if (!this.app.meta.isTest) {
|
|
11
|
+
this.scope.service.queue.loadQueueWorkers(this.ctx.instanceName);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as Bull from 'bullmq';
|
|
2
|
+
import type { VonaApplication } from 'vona';
|
|
3
|
+
|
|
4
|
+
export function config(_app: VonaApplication) {
|
|
5
|
+
return {
|
|
6
|
+
worker: {
|
|
7
|
+
lockDuration: 30 * 1000,
|
|
8
|
+
maxStalledCount: 1000,
|
|
9
|
+
stalledInterval: 10 * 1000,
|
|
10
|
+
} as Bull.WorkerOptions,
|
|
11
|
+
};
|
|
12
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IInstanceRecord } from 'vona';
|
|
2
|
+
|
|
3
|
+
import { BeanBase } from 'vona';
|
|
4
|
+
|
|
5
|
+
import type { IQueuePushOptions, IQueueRecord } from '../types/queue.ts';
|
|
6
|
+
|
|
7
|
+
export class BeanQueueBase<DATA = unknown, RESULT = unknown> extends BeanBase {
|
|
8
|
+
async pushAsync(data: DATA, options?: IQueuePushOptions): Promise<RESULT> {
|
|
9
|
+
return await this.$scope.queue.service.queue.pushAsync<DATA, RESULT>(
|
|
10
|
+
this.$scope.queue.service.queue.prepareJobInfo(this.$onionName as any, data, options),
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
push(data: DATA, options?: IQueuePushOptions) {
|
|
15
|
+
return this.$scope.queue.service.queue.push(this.$scope.queue.service.queue.prepareJobInfo(this.$onionName as any, data, options));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getQueue(instanceName?: keyof IInstanceRecord) {
|
|
19
|
+
return this.$scope.queue.service.queue.getQueue(this.$onionName as keyof IQueueRecord, instanceName);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/lib/index.ts
ADDED
package/src/lib/queue.ts
ADDED
package/src/monkey.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IMonkeyAppClose, IMonkeyAppClosed } from 'vona';
|
|
2
|
+
|
|
3
|
+
import { BeanSimple } from 'vona';
|
|
4
|
+
|
|
5
|
+
import { __ThisModule__ } from './.metadata/this.ts';
|
|
6
|
+
|
|
7
|
+
export class Monkey extends BeanSimple implements IMonkeyAppClose, IMonkeyAppClosed {
|
|
8
|
+
async appClose() {
|
|
9
|
+
const scopeSelf = this.app.scope(__ThisModule__);
|
|
10
|
+
await scopeSelf.service.queue.clearWorkers();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async appClosed() {
|
|
14
|
+
const scopeSelf = this.app.scope(__ThisModule__);
|
|
15
|
+
await scopeSelf.service.queue.clearQueues();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { IInstanceRecord } from 'vona';
|
|
2
|
+
|
|
3
|
+
import * as Bull from 'bullmq';
|
|
4
|
+
import { BeanBase, beanFullNameFromOnionName, deepExtend, instanceDesp, uuidv4 } from 'vona';
|
|
5
|
+
import { Service } from 'vona-module-a-bean';
|
|
6
|
+
import { getRedisClientKeyPrefix } from 'vona-module-a-redis';
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
IQueueCallbacks,
|
|
10
|
+
IQueueExecute,
|
|
11
|
+
IQueueJobContext,
|
|
12
|
+
IQueuePushOptions,
|
|
13
|
+
IQueueQueue,
|
|
14
|
+
IQueueQueues,
|
|
15
|
+
IQueueRecord,
|
|
16
|
+
IQueueWork,
|
|
17
|
+
IQueueWorks,
|
|
18
|
+
TypeQueueJob,
|
|
19
|
+
} from '../types/queue.ts';
|
|
20
|
+
|
|
21
|
+
@Service()
|
|
22
|
+
export class ServiceQueue extends BeanBase {
|
|
23
|
+
_workers: IQueueWorks = {};
|
|
24
|
+
_queues: IQueueQueues = {};
|
|
25
|
+
_queueCallbacks: IQueueCallbacks = {};
|
|
26
|
+
|
|
27
|
+
push<DATA>(info: IQueueJobContext<DATA>) {
|
|
28
|
+
if (!info.options?.dbInfo) throw new Error('should specify the options.dbInfo');
|
|
29
|
+
this._queuePush(info, false);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// { locale, instanceName, module, queueName,queueNameSub,data }
|
|
33
|
+
pushAsync<DATA, RESULT>(info: IQueueJobContext<DATA>): Promise<RESULT> {
|
|
34
|
+
if (!info.options?.dbInfo) throw new Error('should specify the options.dbInfo');
|
|
35
|
+
return this._queuePush(info, true);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
loadQueueWorkers(instanceName?: keyof IInstanceRecord | undefined | null) {
|
|
39
|
+
for (const queueItem of this.bean.onion.queue.getOnionsEnabledCached()) {
|
|
40
|
+
const info: IQueueJobContext<unknown> = {
|
|
41
|
+
queueName: queueItem.name as never,
|
|
42
|
+
data: undefined as any,
|
|
43
|
+
options: {
|
|
44
|
+
instanceName,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
this._ensureWorker(info);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async clearWorkers() {
|
|
52
|
+
for (const queueKey in this._workers) {
|
|
53
|
+
const _worker = this._workers[queueKey];
|
|
54
|
+
await _worker.worker.close();
|
|
55
|
+
}
|
|
56
|
+
this._workers = {};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async clearQueues() {
|
|
60
|
+
for (const queueKey in this._queues) {
|
|
61
|
+
const _queue = this._queues[queueKey];
|
|
62
|
+
await _queue.queue.close();
|
|
63
|
+
await _queue.queueEvents.close();
|
|
64
|
+
}
|
|
65
|
+
this._queues = {};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_getPrefix() {
|
|
69
|
+
return `${getRedisClientKeyPrefix('bull', this.app)}queue`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_createWorker<DATA>(info: IQueueJobContext<DATA>, queueKey: string) {
|
|
73
|
+
const app = this.app;
|
|
74
|
+
// worker
|
|
75
|
+
const _worker = {} as IQueueWork;
|
|
76
|
+
// prefix
|
|
77
|
+
const prefix = this._getPrefix();
|
|
78
|
+
// queue config
|
|
79
|
+
const queueConfig = app.bean.onion.queue.getOnionOptions(info.queueName);
|
|
80
|
+
// queueConfig.options: queue/worker/job/redlock
|
|
81
|
+
const workerOptions = queueConfig?.options?.worker;
|
|
82
|
+
const redlockOptions = queueConfig?.options?.redlock;
|
|
83
|
+
const _lockTTL = redlockOptions?.lockTTL ?? this.$scope.redlock.config.lockTTL;
|
|
84
|
+
|
|
85
|
+
// redlock
|
|
86
|
+
if (!queueConfig?.concurrency) {
|
|
87
|
+
_worker.redlock = this.$scope.redlock.service.redlock.create(redlockOptions);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// create work
|
|
91
|
+
const connectionWorker = app.bean.redis.get('queue');
|
|
92
|
+
const _workerOptions = Object.assign({}, this.scope.config.worker, workerOptions, {
|
|
93
|
+
prefix,
|
|
94
|
+
connection: connectionWorker,
|
|
95
|
+
});
|
|
96
|
+
_worker.workerOptions = _workerOptions;
|
|
97
|
+
_worker.worker = new Bull.Worker(
|
|
98
|
+
queueKey,
|
|
99
|
+
async job => {
|
|
100
|
+
// concurrency
|
|
101
|
+
if (queueConfig?.concurrency) {
|
|
102
|
+
return await this._performTask(job);
|
|
103
|
+
}
|
|
104
|
+
// redlock
|
|
105
|
+
const info = job.data as IQueueJobContext<DATA>;
|
|
106
|
+
const queueNameSub = info.options?.queueNameSub;
|
|
107
|
+
const _lockResource = `queue:${queueKey}${queueNameSub ? `#${queueNameSub}` : ''}`;
|
|
108
|
+
return await this.$scope.redlock.service.redlock.lock(
|
|
109
|
+
_lockResource,
|
|
110
|
+
async () => {
|
|
111
|
+
return await this._performTask(job);
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
// instanceName: job.data.instanceName, // need not
|
|
115
|
+
redlock: _worker.redlock,
|
|
116
|
+
lockTTL: _lockTTL,
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
_workerOptions,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
_worker.worker.on('failed', (_job, err) => {
|
|
124
|
+
this.app.handleError(err);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
_worker.worker.on('error', err => {
|
|
128
|
+
if (err.message && err.message.includes('Missing lock for job')) {
|
|
129
|
+
const workerInner = _worker.worker as any;
|
|
130
|
+
if (!workerInner.running) {
|
|
131
|
+
_worker.worker.run().catch(err => {
|
|
132
|
+
this.app.handleError(err);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// ok
|
|
139
|
+
return _worker;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_createQueue<DATA>(info: IQueueJobContext<DATA>, queueKey: string) {
|
|
143
|
+
const app = this.app;
|
|
144
|
+
// queue
|
|
145
|
+
const _queue = {} as IQueueQueue;
|
|
146
|
+
// prefix
|
|
147
|
+
const prefix = this._getPrefix();
|
|
148
|
+
// queue config
|
|
149
|
+
const queueConfig = app.bean.onion.queue.getOnionOptions(info.queueName);
|
|
150
|
+
// queueConfig.options: queue/worker/job/limiter
|
|
151
|
+
const queueOptions = queueConfig?.options?.queue;
|
|
152
|
+
|
|
153
|
+
// create queue
|
|
154
|
+
const connectionQueue = app.bean.redis.get('queue');
|
|
155
|
+
const _queueOptions = Object.assign({}, queueOptions, { prefix, connection: connectionQueue });
|
|
156
|
+
_queue.config = queueConfig;
|
|
157
|
+
_queue.options = _queueOptions;
|
|
158
|
+
_queue.queue = new Bull.Queue(queueKey, _queueOptions);
|
|
159
|
+
|
|
160
|
+
// create events
|
|
161
|
+
const connectionEvents = app.bean.redis.get('queue');
|
|
162
|
+
const _queueEventsOptions = { prefix, connection: connectionEvents } as Bull.QueueEventsOptions;
|
|
163
|
+
_queue.queueEventsOptions = _queueEventsOptions;
|
|
164
|
+
_queue.queueEvents = new Bull.QueueEvents(queueKey, _queueEventsOptions);
|
|
165
|
+
_queue.queueEvents.on('completed', ({ jobId, returnvalue }) => {
|
|
166
|
+
this._callCallback(jobId, undefined, returnvalue);
|
|
167
|
+
});
|
|
168
|
+
_queue.queueEvents.on('failed', ({ jobId, failedReason }) => {
|
|
169
|
+
this._callCallback(jobId, failedReason, undefined);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// ok
|
|
173
|
+
return _queue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
_ensureWorker<DATA>(info: IQueueJobContext<DATA>) {
|
|
177
|
+
// queueKey
|
|
178
|
+
const queueKey = this._combineQueueKey(info);
|
|
179
|
+
// worker
|
|
180
|
+
if (!this._workers[queueKey]) {
|
|
181
|
+
this._workers[queueKey] = this._createWorker(info, queueKey);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_ensureQueue<DATA>(info: IQueueJobContext<DATA>) {
|
|
186
|
+
// worker
|
|
187
|
+
this._ensureWorker(info);
|
|
188
|
+
// queueKey
|
|
189
|
+
const queueKey = this._combineQueueKey(info);
|
|
190
|
+
// queue
|
|
191
|
+
if (!this._queues[queueKey]) {
|
|
192
|
+
this._queues[queueKey] = this._createQueue(info, queueKey);
|
|
193
|
+
}
|
|
194
|
+
// ok
|
|
195
|
+
return this._queues[queueKey];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
getQueue(queueName: keyof IQueueRecord, instanceName?: keyof IInstanceRecord | undefined | null) {
|
|
199
|
+
return this._getQueue({
|
|
200
|
+
queueName,
|
|
201
|
+
data: undefined as any,
|
|
202
|
+
options: {
|
|
203
|
+
instanceName: instanceName ?? this.ctx.instanceName,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
_getQueue<DATA>(info: IQueueJobContext<DATA>) {
|
|
209
|
+
return this._ensureQueue(info).queue;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
_callCallback<DATA>(jobId: string | number, failedReason: string | undefined, data: DATA | undefined) {
|
|
213
|
+
const _callback = this._queueCallbacks[jobId];
|
|
214
|
+
if (_callback) {
|
|
215
|
+
delete this._queueCallbacks[jobId];
|
|
216
|
+
_callback.callback(failedReason ? new Error(failedReason) : undefined, data);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async _queuePush<DATA, RESULT>(info: IQueueJobContext<DATA>, isAsync: boolean): Promise<RESULT> {
|
|
221
|
+
// queue config
|
|
222
|
+
const queueConfig = this.bean.onion.queue.getOnionOptions(info.queueName);
|
|
223
|
+
// queueConfig.options: queue/worker/job/limiter
|
|
224
|
+
const jobOptionsBase = queueConfig?.options?.job;
|
|
225
|
+
// queue
|
|
226
|
+
const queueQueue = this._ensureQueue(info);
|
|
227
|
+
const queue = queueQueue.queue;
|
|
228
|
+
// job
|
|
229
|
+
const jobId = info.options?.jobOptions?.jobId || uuidv4();
|
|
230
|
+
const jobName = info.options?.jobName || jobId;
|
|
231
|
+
const jobOptions = deepExtend({ jobId }, jobOptionsBase, info.options?.jobOptions);
|
|
232
|
+
// should not change info, hold original info.options?.jobName, info.options?.jobOptions
|
|
233
|
+
// info = deepExtend({}, info, { options: { jobName, jobOptions } });
|
|
234
|
+
// not async
|
|
235
|
+
if (!isAsync) {
|
|
236
|
+
// add job
|
|
237
|
+
queue.add(jobName, info, jobOptions);
|
|
238
|
+
return undefined as any;
|
|
239
|
+
}
|
|
240
|
+
// async
|
|
241
|
+
return new Promise((resolve, reject) => {
|
|
242
|
+
// queue events
|
|
243
|
+
return this._queueEventsReady(queueQueue)
|
|
244
|
+
.then(() => {
|
|
245
|
+
// callback
|
|
246
|
+
this._queueCallbacks[jobId] = {
|
|
247
|
+
info,
|
|
248
|
+
callback: (err, data) => {
|
|
249
|
+
if (err) return reject(err);
|
|
250
|
+
resolve(data as unknown as RESULT);
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
// add job
|
|
254
|
+
return queue.add(jobName, info, jobOptions);
|
|
255
|
+
})
|
|
256
|
+
.catch(err => {
|
|
257
|
+
return reject(err);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async _queueEventsReady(queueQueue: IQueueQueue) {
|
|
263
|
+
if (queueQueue.queueEventsReady) return;
|
|
264
|
+
await queueQueue.queueEvents.waitUntilReady();
|
|
265
|
+
queueQueue.queueEventsReady = true;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
_combineQueueKey<DATA>(info: IQueueJobContext<DATA>) {
|
|
269
|
+
const instanceName = instanceDesp(info.options?.instanceName);
|
|
270
|
+
return `${instanceName}||${beanFullNameFromOnionName(info.queueName, 'queue')}`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async _performTask<DATA, RESULT>(job: TypeQueueJob<DATA, RESULT>) {
|
|
274
|
+
const info = job.data;
|
|
275
|
+
// queue config
|
|
276
|
+
const queueItem = this.bean.onion.queue.getOnionSlice(info.queueName);
|
|
277
|
+
const queueConfig = this.bean.onion.queue.getOnionOptions(info.queueName);
|
|
278
|
+
// execute
|
|
279
|
+
return await this.bean.executor.newCtx(
|
|
280
|
+
async () => {
|
|
281
|
+
const beanFullName = queueItem.beanOptions.beanFullName;
|
|
282
|
+
const beanInstance = <IQueueExecute<DATA>>this.app.bean._getBean(beanFullName as any);
|
|
283
|
+
return await beanInstance.execute(info.data, info.options, job);
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
dbInfo: info.options?.dbInfo,
|
|
287
|
+
locale: info.options?.locale,
|
|
288
|
+
tz: info.options?.tz,
|
|
289
|
+
instanceName: info.options?.instanceName,
|
|
290
|
+
extraData: info.options?.extraData,
|
|
291
|
+
transaction: queueConfig?.transaction,
|
|
292
|
+
},
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
getRepeatKey(jobName: string, repeat: Bull.RepeatOptions) {
|
|
297
|
+
const endDate = repeat.endDate ? new Date(repeat.endDate).getTime() : '';
|
|
298
|
+
const tz = repeat.tz || '';
|
|
299
|
+
const pattern = repeat.pattern;
|
|
300
|
+
const suffix = pattern || String(repeat.every) || '';
|
|
301
|
+
return `${jobName}:${endDate}:${tz}:${suffix}`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
prepareJobInfo<DATA>(queueName: keyof IQueueRecord, data: DATA, options?: IQueuePushOptions): IQueueJobContext<DATA> {
|
|
305
|
+
options = this.$scope.executor.service.executor.prepareGeneralInfo(options);
|
|
306
|
+
// info
|
|
307
|
+
return { queueName, data, options };
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './queue.ts';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type Redlock from '@sesamecare-oss/redlock';
|
|
2
|
+
import type * as Bull from 'bullmq';
|
|
3
|
+
import type { OmitNever, PowerPartial } from 'vona';
|
|
4
|
+
import type { IGeneralInfoOptions } from 'vona-module-a-executor';
|
|
5
|
+
import type { ServiceOnion, TypeOnionOptionsEnableSimple } from 'vona-module-a-onion';
|
|
6
|
+
import type { IRedlockClientOptions } from 'vona-module-a-redlock';
|
|
7
|
+
|
|
8
|
+
export interface IQueuePushOptions extends IGeneralInfoOptions {
|
|
9
|
+
queueNameSub?: string;
|
|
10
|
+
jobName?: string;
|
|
11
|
+
jobOptions?: Bull.JobsOptions;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type TypeQueueJob<DATA = unknown, RESULT = unknown> = Bull.Job<IQueueJobContext<DATA>, RESULT>;
|
|
15
|
+
export interface IQueueExecute<DATA = unknown, RESULT = unknown> {
|
|
16
|
+
execute: (data: DATA, options?: IQueuePushOptions, job?: TypeQueueJob<DATA, RESULT>) => Promise<RESULT>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IQueueJobContext<DATA> {
|
|
20
|
+
queueName: keyof IQueueRecord;
|
|
21
|
+
data: DATA;
|
|
22
|
+
options?: IQueuePushOptions;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IQueueWork {
|
|
26
|
+
redlock: Redlock.Redlock;
|
|
27
|
+
worker: Bull.Worker;
|
|
28
|
+
workerOptions: Bull.WorkerOptions;
|
|
29
|
+
}
|
|
30
|
+
export interface IQueueWorks {
|
|
31
|
+
[queueKey: string]: IQueueWork;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IQueueQueue {
|
|
35
|
+
config?: IDecoratorQueueOptions;
|
|
36
|
+
options: Bull.QueueOptions;
|
|
37
|
+
queue: Bull.Queue;
|
|
38
|
+
queueEvents: Bull.QueueEvents;
|
|
39
|
+
queueEventsOptions: Bull.QueueEventsOptions;
|
|
40
|
+
queueEventsReady?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface IQueueQueues {
|
|
44
|
+
[queueKey: string]: IQueueQueue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface IQueueCallback<DATA, RESULT> {
|
|
48
|
+
info: IQueueJobContext<DATA>;
|
|
49
|
+
callback: (err: Error | undefined, data: RESULT | undefined) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IQueueCallbacks {
|
|
53
|
+
[jobId: string | number]: IQueueCallback<unknown, unknown>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IQueueRecord {}
|
|
57
|
+
|
|
58
|
+
export interface IDecoratorQueueOptions extends TypeOnionOptionsEnableSimple {
|
|
59
|
+
concurrency?: boolean;
|
|
60
|
+
transaction?: boolean;
|
|
61
|
+
options?: {
|
|
62
|
+
queue?: Partial<Bull.QueueOptions>;
|
|
63
|
+
worker?: Partial<Bull.WorkerOptions>;
|
|
64
|
+
redlock?: PowerPartial<IRedlockClientOptions> & { lockTTL?: number };
|
|
65
|
+
job?: Bull.JobsOptions;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare module 'vona-module-a-onion' {
|
|
70
|
+
export interface BeanOnion {
|
|
71
|
+
queue: ServiceOnion<IQueueRecord>;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare module 'vona' {
|
|
76
|
+
export interface ConfigOnions {
|
|
77
|
+
queue: OmitNever<IQueueRecord>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface IBeanSceneRecord {
|
|
81
|
+
queue: never;
|
|
82
|
+
}
|
|
83
|
+
}
|