vona-module-a-queue 5.0.11 → 5.0.13

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.
@@ -1,19 +1,6 @@
1
- import type { BeanScopeUtil, TypeModuleConfig } from 'vona';
2
1
  /** startup: begin */
3
- import type { IDecoratorStartupOptions } from 'vona-module-a-startup';
4
- import type { config } from '../config/config.ts';
5
- /** service: end */
6
- /** service: begin */
7
- import type { ServiceQueue } from '../service/queue.ts';
8
- /** service: end */
9
- /** service: begin */
10
- /** monkey: end */
11
- /** scope: begin */
12
- import { BeanScopeBase } from 'vona';
13
- import 'vona';
14
- import 'vona';
15
- import 'vona';
16
2
  export * from '../bean/startup.loadQueueWorkers.ts';
3
+ import { type IDecoratorStartupOptions } from 'vona-module-a-startup';
17
4
  declare module 'vona-module-a-startup' {
18
5
  interface IStartupRecord {
19
6
  'a-queue:loadQueueWorkers': IDecoratorStartupOptions;
@@ -23,9 +10,10 @@ declare module 'vona-module-a-queue' {
23
10
  interface StartupLoadQueueWorkers {
24
11
  }
25
12
  }
26
- /** service: end */
27
- /** config: begin */
28
- export * from '../config/config.ts';
13
+ /** startup: end */
14
+ /** service: begin */
15
+ export * from '../service/queue.ts';
16
+ import 'vona';
29
17
  declare module 'vona-module-a-web' {
30
18
  interface IServiceRecord {
31
19
  'a-queue:queue': never;
@@ -35,20 +23,30 @@ declare module 'vona-module-a-queue' {
35
23
  interface ServiceQueue {
36
24
  }
37
25
  }
26
+ /** service: end */
27
+ /** service: begin */
28
+ import type { ServiceQueue } from '../service/queue.ts';
38
29
  export interface IModuleService {
39
- queue: ServiceQueue;
30
+ 'queue': ServiceQueue;
40
31
  }
32
+ /** service: end */
33
+ /** service: begin */
34
+ import 'vona';
41
35
  declare module 'vona' {
42
36
  interface IBeanRecordGeneral {
43
37
  'a-queue.service.queue': ServiceQueue;
44
38
  }
45
39
  }
40
+ /** service: end */
41
+ /** config: begin */
42
+ export * from '../config/config.ts';
43
+ import type { config } from '../config/config.ts';
46
44
  /** config: end */
47
45
  /** monkey: begin */
48
46
  export * from '../monkey.ts';
49
- /** startup: end */
50
- /** service: begin */
51
- export * from '../service/queue.ts';
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,8 +1,8 @@
1
- import { BeanInfo, BeanBase, BeanSimple, uuidv4, deepExtend, instanceDesp, beanFullNameFromOnionName, BeanScopeBase, createBeanDecorator } from 'vona';
2
- import { Scope } from 'vona-module-a-bean';
1
+ import { BeanInfo, BeanBase, uuidv4, deepExtend, instanceDesp, beanFullNameFromOnionName, BeanSimple, BeanScopeBase, createBeanDecorator } from 'vona';
3
2
  import { Startup } from 'vona-module-a-startup';
4
3
  import * as Bull from 'bullmq';
5
4
  import { Service } from 'vona-module-a-web';
5
+ import { Scope } from 'vona-module-a-bean';
6
6
 
7
7
  var _dec$2, _dec2$2, _class$2;
8
8
  let StartupLoadQueueWorkers = (_dec$2 = Startup({
@@ -19,29 +19,6 @@ let StartupLoadQueueWorkers = (_dec$2 = Startup({
19
19
  }
20
20
  }) || _class$2) || _class$2);
21
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
22
  var _dec$1, _dec2$1, _class$1;
46
23
  let ServiceQueue = (_dec$1 = Service(), _dec2$1 = BeanInfo({
47
24
  module: "a-queue"
@@ -308,6 +285,29 @@ let ServiceQueue = (_dec$1 = Service(), _dec2$1 = BeanInfo({
308
285
  }
309
286
  }) || _class$1) || _class$1);
310
287
 
288
+ function config(_app) {
289
+ return {
290
+ worker: {
291
+ lockDuration: 30 * 1000,
292
+ maxStalledCount: 1000,
293
+ stalledInterval: 10 * 1000
294
+ }
295
+ };
296
+ }
297
+
298
+ const __ThisModule__ = 'a-queue';
299
+
300
+ class Monkey extends BeanSimple {
301
+ async appClose() {
302
+ const scopeSelf = this.bean.scope(__ThisModule__);
303
+ await scopeSelf.service.queue.clearWorkers();
304
+ }
305
+ async appClosed() {
306
+ const scopeSelf = this.bean.scope(__ThisModule__);
307
+ await scopeSelf.service.queue.clearQueues();
308
+ }
309
+ }
310
+
311
311
  var _dec, _dec2, _class;
312
312
  let ScopeModuleAQueue = (_dec = Scope(), _dec2 = BeanInfo({
313
313
  module: "a-queue"
@@ -1,7 +1,8 @@
1
+ import type { IInstanceRecord } from 'vona';
1
2
  import type { IQueuePushOptions } from '../types/queue.ts';
2
3
  import { BeanBase } from 'vona';
3
4
  export declare class BeanQueueBase<DATA = unknown, RESULT = unknown> extends BeanBase {
4
5
  pushAsync(data: DATA, options?: IQueuePushOptions): Promise<RESULT>;
5
6
  push(data: DATA, options?: IQueuePushOptions): void;
6
- getQueue(instanceName?: string): import("bullmq").Queue<any, any, string, any, any, string>;
7
+ getQueue(instanceName?: keyof IInstanceRecord): import("bullmq").Queue<any, any, string, any, any, string>;
7
8
  }
@@ -1,3 +1,4 @@
1
+ import type { IInstanceRecord } from 'vona';
1
2
  import type { IQueueCallbacks, IQueueJobContext, IQueuePushOptions, IQueueQueue, IQueueQueues, IQueueRecord, IQueueWork, IQueueWorks, TypeQueueJob } from '../types/queue.ts';
2
3
  import * as Bull from 'bullmq';
3
4
  import { BeanBase } from 'vona';
@@ -7,14 +8,14 @@ export declare class ServiceQueue extends BeanBase {
7
8
  _queueCallbacks: IQueueCallbacks;
8
9
  push<DATA>(info: IQueueJobContext<DATA>): void;
9
10
  pushAsync<DATA, RESULT>(info: IQueueJobContext<DATA>): Promise<RESULT>;
10
- loadQueueWorkers(instanceName?: string | undefined | null): void;
11
+ loadQueueWorkers(instanceName?: keyof IInstanceRecord | undefined | null): void;
11
12
  clearWorkers(): Promise<void>;
12
13
  clearQueues(): Promise<void>;
13
14
  _createWorker<DATA>(info: IQueueJobContext<DATA>, queueKey: string): IQueueWork;
14
15
  _createQueue<DATA>(info: IQueueJobContext<DATA>, queueKey: string): IQueueQueue;
15
16
  _ensureWorker<DATA>(info: IQueueJobContext<DATA>): void;
16
17
  _ensureQueue<DATA>(info: IQueueJobContext<DATA>): IQueueQueue;
17
- getQueue(queueName: keyof IQueueRecord, instanceName?: string | undefined | null): Bull.Queue<any, any, string, any, any, string>;
18
+ getQueue(queueName: keyof IQueueRecord, instanceName?: keyof IInstanceRecord | undefined | null): Bull.Queue<any, any, string, any, any, string>;
18
19
  _getQueue<DATA>(info: IQueueJobContext<DATA>): Bull.Queue<any, any, string, any, any, string>;
19
20
  _callCallback<DATA>(jobId: string | number, failedReason: string | undefined, data: DATA | undefined): void;
20
21
  _queuePush<DATA, RESULT>(info: IQueueJobContext<DATA>, isAsync: boolean): Promise<RESULT>;
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.11",
4
+ "version": "5.0.13",
5
5
  "title": "a-queue",
6
6
  "vonaModule": {
7
7
  "dependencies": {},