@forklaunch/implementation-worker-bullmq 0.3.1 → 0.3.2

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.
@@ -33,7 +33,7 @@ var BullMqWorkerConsumer = class {
33
33
  this.processEvents = processEvents;
34
34
  this.failureHandler = failureHandler;
35
35
  this.queue = new import_bullmq.Queue(this.queueName, {
36
- connection: this.options.connection
36
+ connection: this.options.queueOptions.connection
37
37
  });
38
38
  }
39
39
  queue;
@@ -49,7 +49,7 @@ var BullMqWorkerConsumer = class {
49
49
  const event = job.data;
50
50
  await this.processEvents([event]);
51
51
  },
52
- this.options
52
+ this.options.queueOptions
53
53
  );
54
54
  this.worker.on("failed", (job, error) => {
55
55
  if (job) {
@@ -7,7 +7,7 @@ var BullMqWorkerConsumer = class {
7
7
  this.processEvents = processEvents;
8
8
  this.failureHandler = failureHandler;
9
9
  this.queue = new Queue(this.queueName, {
10
- connection: this.options.connection
10
+ connection: this.options.queueOptions.connection
11
11
  });
12
12
  }
13
13
  queue;
@@ -23,7 +23,7 @@ var BullMqWorkerConsumer = class {
23
23
  const event = job.data;
24
24
  await this.processEvents([event]);
25
25
  },
26
- this.options
26
+ this.options.queueOptions
27
27
  );
28
28
  this.worker.on("failed", (job, error) => {
29
29
  if (job) {
@@ -22,7 +22,7 @@ export class BullMqWorkerConsumer<
22
22
  protected readonly failureHandler: WorkerFailureHandler<EventEntity>
23
23
  ) {
24
24
  this.queue = new Queue(this.queueName, {
25
- connection: this.options.connection
25
+ connection: this.options.queueOptions.connection
26
26
  });
27
27
  }
28
28
 
@@ -38,7 +38,7 @@ export class BullMqWorkerConsumer<
38
38
  const event = job.data as EventEntity;
39
39
  await this.processEvents([event]);
40
40
  },
41
- this.options
41
+ this.options.queueOptions
42
42
  );
43
43
 
44
44
  this.worker.on('failed', (job: Job | undefined, error: Error) => {
@@ -1,154 +1,8 @@
1
- import {
2
- any,
3
- array,
4
- boolean,
5
- date,
6
- enum_,
7
- function_,
8
- literal,
9
- null_,
10
- number,
11
- optional,
12
- promise,
13
- record,
14
- string,
15
- undefined_,
16
- union,
17
- unknown,
18
- void_
19
- } from '@{{app_name}}/core';
20
- import { SpanKind } from 'bullmq';
21
-
22
- const BullMqWorkerKeepJobsSchema = {
23
- age: optional(number),
24
- count: optional(number)
25
- };
26
-
27
- const BullMqWorkerBackoffOptionsSchema = {
28
- type: union([literal('fixed'), literal('exponential')]),
29
- delay: optional(number)
30
- };
31
-
32
- const BullMqWorkerDefaultJobOptionsSchema = {
33
- timestamp: optional(number),
34
- priority: optional(number),
35
- delay: optional(number),
36
- attempts: optional(number),
37
- backoff: optional(union([number, BullMqWorkerBackoffOptionsSchema])),
38
- lifo: optional(boolean),
39
- removeOnComplete: optional(
40
- union([boolean, number, BullMqWorkerKeepJobsSchema])
41
- ),
42
- removeOnFail: optional(union([boolean, number, BullMqWorkerKeepJobsSchema])),
43
- keepLogs: optional(number),
44
- stackTraceLimit: optional(number),
45
- sizeLimit: optional(number)
46
- };
47
-
48
- const BullMqDateType = union([date, number, string]);
49
-
50
- const BullMqWorkerAdvancedRepeatOptionsSchema = {
51
- repeatStrategy: optional(
52
- function_(
53
- [
54
- number,
55
- {
56
- pattern: optional(string),
57
- key: optional(string),
58
- limit: optional(number),
59
- every: optional(number),
60
- immediately: optional(boolean),
61
- count: optional(number),
62
- offset: optional(number),
63
- prevMillis: optional(number),
64
- jobId: optional(string),
65
- currentDate: optional(BullMqDateType),
66
- startDate: optional(BullMqDateType),
67
- endDate: optional(BullMqDateType),
68
- utc: optional(boolean),
69
- tz: optional(string),
70
- nthDayOfWeek: optional(number)
71
- },
72
- optional(string)
73
- ],
74
- union([number, undefined_, promise(union([number, undefined_]))])
75
- )
76
- ),
77
- repeatKeyHashAlgorithm: optional(string)
78
- };
79
-
80
- const BullMqWorkerTelemetryAttributeValueSchema = union([
81
- string,
82
- number,
83
- boolean,
84
- array(union([string, null_, undefined_])),
85
- array(union([number, null_, undefined_])),
86
- array(union([boolean, null_, undefined_]))
87
- ]);
88
-
89
- const BullMqWorkerTelemetryAttributesSchema = record(
90
- string,
91
- union([BullMqWorkerTelemetryAttributeValueSchema, undefined_])
92
- );
93
-
94
- const BullMqWorkerTelemetrySchema = optional({
95
- tracer: {
96
- startSpan: function_(
97
- [
98
- string,
99
- optional({
100
- kind: optional(enum_(SpanKind))
101
- }),
102
- optional(unknown)
103
- ],
104
- {
105
- setSpanOnContext: function_([unknown], unknown),
106
- setAttribute: function_(
107
- [string, BullMqWorkerTelemetryAttributeValueSchema],
108
- void_
109
- ),
110
- setAttributes: function_(
111
- [BullMqWorkerTelemetryAttributesSchema],
112
- void_
113
- ),
114
- addEvent: function_(
115
- [string, optional(BullMqWorkerTelemetryAttributesSchema)],
116
- void_
117
- ),
118
- recordException: function_([unknown, optional(number)], void_),
119
- end: function_([], void_)
120
- }
121
- )
122
- },
123
- contextManager: {
124
- with: function_([unknown, function_([any], any)], any),
125
- active: function_([], unknown),
126
- getMetadata: function_([unknown], string),
127
- fromMetadata: function_([unknown, string], unknown)
128
- }
129
- });
130
-
131
- const BullMqWorkerQueueOptionsSchema = {
132
- connection: {
133
- skipVersionCheck: optional(boolean),
134
- url: optional(string)
135
- },
136
- blockingConnection: optional(boolean),
137
- prefix: optional(string),
138
- telemetry: BullMqWorkerTelemetrySchema,
139
- skipWaitingForReady: optional(boolean),
140
- defaultJobOptions: optional(BullMqWorkerDefaultJobOptionsSchema),
141
- streams: optional({
142
- events: {
143
- maxLen: number
144
- }
145
- }),
146
- skipMetasUpdate: optional(boolean),
147
- settings: optional(BullMqWorkerAdvancedRepeatOptionsSchema)
148
- };
1
+ import { literal, number, type, union } from '@{{app_name}}/core';
2
+ import { QueueOptions } from 'bullmq';
149
3
 
150
4
  export const BullMqWorkerOptionsSchema = {
151
- ...BullMqWorkerQueueOptionsSchema,
5
+ queueOptions: type<QueueOptions>(),
152
6
  backoffType: union([literal('exponential'), literal('fixed')]),
153
7
  retries: number,
154
8
  interval: number
@@ -15,7 +15,7 @@ export class BullMqWorkerProducer<
15
15
  private readonly options: Options
16
16
  ) {
17
17
  this.queue = new Queue(this.queueName, {
18
- connection: this.options.connection
18
+ connection: this.options.queueOptions.connection
19
19
  });
20
20
  }
21
21
 
@@ -1,6 +1,7 @@
1
1
  import { QueueOptions } from 'bullmq';
2
2
 
3
- export type BullMqWorkerOptions = QueueOptions & {
3
+ export type BullMqWorkerOptions = {
4
+ queueOptions: QueueOptions;
4
5
  backoffType: 'exponential' | 'fixed';
5
6
  retries: number;
6
7
  interval: number;
@@ -31,7 +31,7 @@ var BullMqWorkerProducer = class {
31
31
  this.queueName = queueName;
32
32
  this.options = options;
33
33
  this.queue = new import_bullmq.Queue(this.queueName, {
34
- connection: this.options.connection
34
+ connection: this.options.queueOptions.connection
35
35
  });
36
36
  }
37
37
  queue;
@@ -5,7 +5,7 @@ var BullMqWorkerProducer = class {
5
5
  this.queueName = queueName;
6
6
  this.options = options;
7
7
  this.queue = new Queue(this.queueName, {
8
- connection: this.options.connection
8
+ connection: this.options.queueOptions.connection
9
9
  });
10
10
  }
11
11
  queue;