vona-module-a-queue 5.0.28 → 5.0.30

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.
@@ -8,7 +8,6 @@ export type TypeQueue<%=argv.beanNameCapitalize%>JobResult = void;
8
8
  @Queue()
9
9
  export class Queue<%=argv.beanNameCapitalize%>
10
10
  extends BeanQueueBase<TypeQueue<%=argv.beanNameCapitalize%>JobData, TypeQueue<%=argv.beanNameCapitalize%>JobResult>
11
- implements IQueueExecute<TypeQueue<%=argv.beanNameCapitalize%>JobData, TypeQueue<%=argv.beanNameCapitalize%>JobResult>
12
- {
11
+ implements IQueueExecute<TypeQueue<%=argv.beanNameCapitalize%>JobData, TypeQueue<%=argv.beanNameCapitalize%>JobResult> {
13
12
  async execute(_data: TypeQueue<%=argv.beanNameCapitalize%>JobData, _options?: IQueuePushOptions): Promise<TypeQueue<%=argv.beanNameCapitalize%>JobResult> {}
14
13
  }
@@ -47,6 +47,23 @@ declare module 'vona-module-a-queue' {
47
47
  }
48
48
  }
49
49
  /** startup: end */
50
+ /** hmr: begin */
51
+ export * from '../bean/hmr.queue.ts';
52
+ import 'vona';
53
+ declare module 'vona' {
54
+ interface IHmrRecord {
55
+ 'a-queue:queue': never;
56
+ }
57
+ }
58
+ declare module 'vona-module-a-queue' {
59
+ interface HmrQueue {
60
+ }
61
+ interface HmrQueue {
62
+ get $beanFullName(): 'a-queue.hmr.queue';
63
+ get $onionName(): 'a-queue:queue';
64
+ }
65
+ }
66
+ /** hmr: end */
50
67
  /** config: begin */
51
68
  export * from '../config/config.ts';
52
69
  import type { config } from '../config/config.ts';
@@ -0,0 +1,6 @@
1
+ import type { IDecoratorBeanOptionsBase } from 'vona';
2
+ import type { IHmrReload } from 'vona-module-a-hmr';
3
+ import { BeanBase } from 'vona';
4
+ export declare class HmrQueue extends BeanBase implements IHmrReload {
5
+ reload(_beanOptions: IDecoratorBeanOptionsBase): Promise<void>;
6
+ }
package/dist/index.js CHANGED
@@ -4,11 +4,12 @@ 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-hmr';
7
8
 
8
- var _dec$2, _dec2$2, _class$2;
9
- let ServiceQueue = (_dec$2 = Service(), _dec2$2 = BeanInfo({
9
+ var _dec$3, _dec2$3, _class$3;
10
+ let ServiceQueue = (_dec$3 = Service(), _dec2$3 = BeanInfo({
10
11
  module: "a-queue"
11
- }), _dec$2(_class$2 = _dec2$2(_class$2 = class ServiceQueue extends BeanBase {
12
+ }), _dec$3(_class$3 = _dec2$3(_class$3 = class ServiceQueue extends BeanBase {
12
13
  constructor(...args) {
13
14
  super(...args);
14
15
  this._workers = {};
@@ -26,7 +27,7 @@ let ServiceQueue = (_dec$2 = Service(), _dec2$2 = BeanInfo({
26
27
  return this._queuePush(info, true);
27
28
  }
28
29
  loadQueueWorkers(instanceName) {
29
- for (const queueItem of this.bean.onion.queue.getOnionsEnabled()) {
30
+ for (const queueItem of this.bean.onion.queue.getOnionsEnabledCached()) {
30
31
  const info = {
31
32
  queueName: queueItem.name,
32
33
  data: undefined,
@@ -66,12 +67,11 @@ let ServiceQueue = (_dec$2 = Service(), _dec2$2 = BeanInfo({
66
67
  // queueConfig.options: queue/worker/job/redlock
67
68
  const workerOptions = queueConfig?.options?.worker;
68
69
  const redlockOptions = queueConfig?.options?.redlock;
69
- const _redlockOptions = Object.assign({}, this.$scope.redlock.config.redlock.options, redlockOptions);
70
- const _lockTTL = redlockOptions?.lockTTL ?? this.$scope.redlock.config.redlock.lockTTL;
70
+ const _lockTTL = redlockOptions?.lockTTL ?? this.$scope.redlock.config.lockTTL;
71
71
 
72
72
  // redlock
73
73
  if (!queueConfig?.concurrency) {
74
- _worker.redlock = this.$scope.redlock.service.redlock.create(_redlockOptions);
74
+ _worker.redlock = this.$scope.redlock.service.redlock.create(redlockOptions);
75
75
  }
76
76
 
77
77
  // create work
@@ -266,6 +266,7 @@ let ServiceQueue = (_dec$2 = Service(), _dec2$2 = BeanInfo({
266
266
  }, {
267
267
  dbInfo: info.options?.dbInfo,
268
268
  locale: info.options?.locale,
269
+ tz: info.options?.tz,
269
270
  instanceName: info.options?.instanceName,
270
271
  extraData: info.options?.extraData,
271
272
  transaction: queueConfig?.transaction
@@ -287,21 +288,30 @@ let ServiceQueue = (_dec$2 = Service(), _dec2$2 = BeanInfo({
287
288
  options
288
289
  };
289
290
  }
290
- }) || _class$2) || _class$2);
291
+ }) || _class$3) || _class$3);
291
292
 
292
- var _dec$1, _dec2$1, _class$1;
293
- let StartupLoadQueueWorkers = (_dec$1 = Startup({
293
+ var _dec$2, _dec2$2, _class$2;
294
+ let StartupLoadQueueWorkers = (_dec$2 = Startup({
294
295
  instance: true,
295
296
  after: true
296
- }), _dec2$1 = BeanInfo({
297
+ }), _dec2$2 = BeanInfo({
297
298
  module: "a-queue"
298
- }), _dec$1(_class$1 = _dec2$1(_class$1 = class StartupLoadQueueWorkers extends BeanBase {
299
+ }), _dec$2(_class$2 = _dec2$2(_class$2 = class StartupLoadQueueWorkers extends BeanBase {
299
300
  async execute() {
300
301
  // load queue workers
301
302
  if (!this.app.meta.isTest) {
302
303
  this.scope.service.queue.loadQueueWorkers(this.ctx.instanceName);
303
304
  }
304
305
  }
306
+ }) || _class$2) || _class$2);
307
+
308
+ var _dec$1, _dec2$1, _class$1;
309
+ let HmrQueue = (_dec$1 = Hmr(), _dec2$1 = BeanInfo({
310
+ module: "a-queue"
311
+ }), _dec$1(_class$1 = _dec2$1(_class$1 = class HmrQueue extends BeanBase {
312
+ async reload(_beanOptions) {
313
+ this.app.bean.worker.reload();
314
+ }
305
315
  }) || _class$1) || _class$1);
306
316
 
307
317
  function config(_app) {
@@ -353,4 +363,4 @@ function Queue(options) {
353
363
  return createBeanDecorator('queue', options);
354
364
  }
355
365
 
356
- export { BeanQueueBase, Monkey, Queue, ScopeModuleAQueue, ServiceQueue, StartupLoadQueueWorkers, config };
366
+ export { BeanQueueBase, HmrQueue, Monkey, Queue, ScopeModuleAQueue, ServiceQueue, StartupLoadQueueWorkers, config };
@@ -1,8 +1,9 @@
1
1
  import type Redlock from '@sesamecare-oss/redlock';
2
2
  import type * as Bull from 'bullmq';
3
- import type { OmitNever } from 'vona';
3
+ import type { OmitNever, PowerPartial } from 'vona';
4
4
  import type { IGeneralInfoOptions } from 'vona-module-a-executor';
5
5
  import type { ServiceOnion, TypeOnionOptionsEnableSimple } from 'vona-module-a-onion';
6
+ import type { IRedlockClientOptions } from 'vona-module-a-redlock';
6
7
  export interface IQueuePushOptions extends IGeneralInfoOptions {
7
8
  queueNameSub?: string;
8
9
  jobName?: string;
@@ -51,7 +52,7 @@ export interface IDecoratorQueueOptions extends TypeOnionOptionsEnableSimple {
51
52
  options?: {
52
53
  queue?: Partial<Bull.QueueOptions>;
53
54
  worker?: Partial<Bull.WorkerOptions>;
54
- redlock?: Partial<Redlock.Redlock> & {
55
+ redlock?: PowerPartial<IRedlockClientOptions> & {
55
56
  lockTTL?: number;
56
57
  };
57
58
  job?: Bull.JobsOptions;
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.28",
4
+ "version": "5.0.30",
5
5
  "title": "a-queue",
6
6
  "vonaModule": {
7
7
  "dependencies": {},