@forklaunch/implementation-worker-bullmq 0.1.1 → 0.1.3
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/package.json +3 -3
- package/lib/__test__/schemaEquality.test.d.ts +0 -2
- package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
- package/lib/__test__/schemaEquality.test.js +0 -24
- package/lib/consumers/bullMqWorker.consumer.d.ts +0 -29
- package/lib/consumers/bullMqWorker.consumer.d.ts.map +0 -1
- package/lib/consumers/bullMqWorker.consumer.js +0 -46
- package/lib/consumers/index.d.ts +0 -2
- package/lib/consumers/index.d.ts.map +0 -1
- package/lib/consumers/index.js +0 -1
- package/lib/eject/consumers/bullMqWorker.consumer.ts +0 -60
- package/lib/eject/consumers/index.ts +0 -1
- package/lib/eject/domain/schemas/bullMqWorker.schema.ts +0 -155
- package/lib/eject/domain/schemas/index.ts +0 -1
- package/lib/eject/producers/bullMqWorker.producer.ts +0 -46
- package/lib/eject/producers/index.ts +0 -1
- package/lib/eject/types/bullMqWorker.types.ts +0 -7
- package/lib/eject/types/index.ts +0 -1
- package/lib/jest.config.d.ts +0 -4
- package/lib/jest.config.d.ts.map +0 -1
- package/lib/jest.config.js +0 -19
- package/lib/producers/bullMqWorker.producer.d.ts +0 -16
- package/lib/producers/bullMqWorker.producer.d.ts.map +0 -1
- package/lib/producers/bullMqWorker.producer.js +0 -37
- package/lib/producers/index.d.ts +0 -2
- package/lib/producers/index.d.ts.map +0 -1
- package/lib/producers/index.js +0 -1
- package/lib/schemas/bullMqWorker.schema.d.ts +0 -1975
- package/lib/schemas/bullMqWorker.schema.d.ts.map +0 -1
- package/lib/schemas/bullMqWorker.schema.js +0 -7
- package/lib/schemas/index.d.ts +0 -2
- package/lib/schemas/index.d.ts.map +0 -1
- package/lib/schemas/index.js +0 -1
- package/lib/schemas/typebox/bullMqWorker.schema.d.ts +0 -1022
- package/lib/schemas/typebox/bullMqWorker.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/bullMqWorker.schema.js +0 -145
- package/lib/schemas/zod/bullMqWorker.schema.d.ts +0 -920
- package/lib/schemas/zod/bullMqWorker.schema.d.ts.map +0 -1
- package/lib/schemas/zod/bullMqWorker.schema.js +0 -145
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/bullMqWorker.types.d.ts +0 -7
- package/lib/types/bullMqWorker.types.d.ts.map +0 -1
- package/lib/types/bullMqWorker.types.js +0 -1
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/index.js +0 -1
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-worker-bullmq",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "BullMQ implementation for forklaunch workers",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"lib/**"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@forklaunch/core": "
|
|
41
|
+
"@forklaunch/core": "^0.7.4",
|
|
42
42
|
"@sinclair/typebox": "^0.34.33",
|
|
43
43
|
"bullmq": "^5.49.1",
|
|
44
44
|
"zod": "^3.24.3",
|
|
45
|
-
"@forklaunch/interfaces-worker": "0.1.
|
|
45
|
+
"@forklaunch/interfaces-worker": "0.1.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"depcheck": "^1.4.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemaEquality.test.d.ts","sourceRoot":"","sources":["../../__test__/schemaEquality.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { isTrue } from '@forklaunch/common';
|
|
2
|
-
import { testSchemaEquality } from '@forklaunch/core/test';
|
|
3
|
-
import { BullMqWorkerOptionsSchema as TypeboxBullMqWorkerOptionsSchema } from '../schemas/typebox/bullMqWorker.schema';
|
|
4
|
-
import { BullMqWorkerOptionsSchema as ZodBullMqWorkerOptionsSchema } from '../schemas/zod/bullMqWorker.schema';
|
|
5
|
-
describe('schema equality', () => {
|
|
6
|
-
it('should be equal for bullmq worker', () => {
|
|
7
|
-
expect(
|
|
8
|
-
isTrue(
|
|
9
|
-
testSchemaEquality(
|
|
10
|
-
ZodBullMqWorkerOptionsSchema,
|
|
11
|
-
TypeboxBullMqWorkerOptionsSchema,
|
|
12
|
-
{
|
|
13
|
-
backoffType: 'fixed',
|
|
14
|
-
retries: 1,
|
|
15
|
-
interval: 1000,
|
|
16
|
-
connection: {
|
|
17
|
-
url: 'redis://localhost:6379'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
)
|
|
22
|
-
).toBeTruthy();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
3
|
-
WorkerEventEntity,
|
|
4
|
-
WorkerFailureHandler,
|
|
5
|
-
WorkerProcessFunction
|
|
6
|
-
} from '@forklaunch/interfaces-worker/types';
|
|
7
|
-
import { BullMqWorkerOptions } from '../types/bullMqWorker.types';
|
|
8
|
-
export declare class BullMqWorkerConsumer<
|
|
9
|
-
EventEntity extends WorkerEventEntity,
|
|
10
|
-
Options extends BullMqWorkerOptions
|
|
11
|
-
> implements WorkerConsumer<EventEntity>
|
|
12
|
-
{
|
|
13
|
-
protected readonly queueName: string;
|
|
14
|
-
protected readonly options: Options;
|
|
15
|
-
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
16
|
-
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
17
|
-
private queue;
|
|
18
|
-
private worker?;
|
|
19
|
-
constructor(
|
|
20
|
-
queueName: string,
|
|
21
|
-
options: Options,
|
|
22
|
-
processEvents: WorkerProcessFunction<EventEntity>,
|
|
23
|
-
failureHandler: WorkerFailureHandler<EventEntity>
|
|
24
|
-
);
|
|
25
|
-
peekEvents(): Promise<EventEntity[]>;
|
|
26
|
-
start(): Promise<void>;
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=bullMqWorker.consumer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bullMqWorker.consumer.d.ts","sourceRoot":"","sources":["../../consumers/bullMqWorker.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,qBAAa,oBAAoB,CAC/B,WAAW,SAAS,iBAAiB,EACrC,OAAO,SAAS,mBAAmB,CACnC,YAAW,cAAc,CAAC,WAAW,CAAC;IAMpC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM;IACpC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO;IACnC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC,WAAW,CAAC;IACpE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAPtE,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,MAAM,CAAC,CAAS;gBAGH,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,qBAAqB,CAAC,WAAW,CAAC,EACjD,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAOhE,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAKpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Queue, Worker } from 'bullmq';
|
|
2
|
-
export class BullMqWorkerConsumer {
|
|
3
|
-
queueName;
|
|
4
|
-
options;
|
|
5
|
-
processEvents;
|
|
6
|
-
failureHandler;
|
|
7
|
-
queue;
|
|
8
|
-
worker;
|
|
9
|
-
constructor(queueName, options, processEvents, failureHandler) {
|
|
10
|
-
this.queueName = queueName;
|
|
11
|
-
this.options = options;
|
|
12
|
-
this.processEvents = processEvents;
|
|
13
|
-
this.failureHandler = failureHandler;
|
|
14
|
-
this.queue = new Queue(this.queueName, {
|
|
15
|
-
connection: this.options.connection
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
async peekEvents() {
|
|
19
|
-
const jobs = await this.queue.getJobs(['waiting', 'active']);
|
|
20
|
-
return jobs.map((job) => job.data);
|
|
21
|
-
}
|
|
22
|
-
async start() {
|
|
23
|
-
this.worker = new Worker(
|
|
24
|
-
this.queueName,
|
|
25
|
-
async (job) => {
|
|
26
|
-
const event = job.data;
|
|
27
|
-
await this.processEvents([event]);
|
|
28
|
-
},
|
|
29
|
-
this.options
|
|
30
|
-
);
|
|
31
|
-
this.worker.on('failed', (job, error) => {
|
|
32
|
-
if (job) {
|
|
33
|
-
this.failureHandler([
|
|
34
|
-
{
|
|
35
|
-
value: job.data,
|
|
36
|
-
error
|
|
37
|
-
}
|
|
38
|
-
]);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
async close() {
|
|
43
|
-
await this.worker?.close();
|
|
44
|
-
await this.queue.close();
|
|
45
|
-
}
|
|
46
|
-
}
|
package/lib/consumers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/lib/consumers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bullMqWorker.consumer';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
3
|
-
WorkerEventEntity,
|
|
4
|
-
WorkerFailureHandler,
|
|
5
|
-
WorkerProcessFunction
|
|
6
|
-
} from '@forklaunch/interfaces-worker/types';
|
|
7
|
-
import { Job, Queue, Worker } from 'bullmq';
|
|
8
|
-
import { BullMqWorkerOptions } from '../types/bullMqWorker.types';
|
|
9
|
-
|
|
10
|
-
export class BullMqWorkerConsumer<
|
|
11
|
-
EventEntity extends WorkerEventEntity,
|
|
12
|
-
Options extends BullMqWorkerOptions
|
|
13
|
-
> implements WorkerConsumer<EventEntity>
|
|
14
|
-
{
|
|
15
|
-
private queue: Queue;
|
|
16
|
-
private worker?: Worker;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
protected readonly queueName: string,
|
|
20
|
-
protected readonly options: Options,
|
|
21
|
-
protected readonly processEvents: WorkerProcessFunction<EventEntity>,
|
|
22
|
-
protected readonly failureHandler: WorkerFailureHandler<EventEntity>
|
|
23
|
-
) {
|
|
24
|
-
this.queue = new Queue(this.queueName, {
|
|
25
|
-
connection: this.options.connection
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async peekEvents(): Promise<EventEntity[]> {
|
|
30
|
-
const jobs = await this.queue.getJobs(['waiting', 'active']);
|
|
31
|
-
return jobs.map((job) => job.data as EventEntity);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async start(): Promise<void> {
|
|
35
|
-
this.worker = new Worker(
|
|
36
|
-
this.queueName,
|
|
37
|
-
async (job: Job) => {
|
|
38
|
-
const event = job.data as EventEntity;
|
|
39
|
-
await this.processEvents([event]);
|
|
40
|
-
},
|
|
41
|
-
this.options
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
this.worker.on('failed', (job: Job | undefined, error: Error) => {
|
|
45
|
-
if (job) {
|
|
46
|
-
this.failureHandler([
|
|
47
|
-
{
|
|
48
|
-
value: job.data as EventEntity,
|
|
49
|
-
error
|
|
50
|
-
}
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async close(): Promise<void> {
|
|
57
|
-
await this.worker?.close();
|
|
58
|
-
await this.queue.close();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bullMqWorker.consumer';
|
|
@@ -1,155 +0,0 @@
|
|
|
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
|
-
};
|
|
149
|
-
|
|
150
|
-
export const BullMqWorkerOptionsSchema = {
|
|
151
|
-
...BullMqWorkerQueueOptionsSchema,
|
|
152
|
-
backoffType: union([literal('exponential'), literal('fixed')]),
|
|
153
|
-
retries: number,
|
|
154
|
-
interval: number
|
|
155
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bullMqWorker.schema';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { WorkerProducer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import { WorkerEventEntity } from '@forklaunch/interfaces-worker/types';
|
|
3
|
-
import { Queue } from 'bullmq';
|
|
4
|
-
import { BullMqWorkerOptions } from '../types/bullMqWorker.types';
|
|
5
|
-
|
|
6
|
-
export class BullMqWorkerProducer<
|
|
7
|
-
EventEntity extends WorkerEventEntity,
|
|
8
|
-
Options extends BullMqWorkerOptions
|
|
9
|
-
> implements WorkerProducer<EventEntity>
|
|
10
|
-
{
|
|
11
|
-
private queue;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
private readonly queueName: string,
|
|
15
|
-
private readonly options: Options
|
|
16
|
-
) {
|
|
17
|
-
this.queue = new Queue(this.queueName, {
|
|
18
|
-
connection: this.options.connection
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async enqueueJob(event: EventEntity): Promise<void> {
|
|
23
|
-
await this.queue.add(event.id, event, {
|
|
24
|
-
attempts: this.options.retries,
|
|
25
|
-
backoff: {
|
|
26
|
-
type: this.options.backoffType,
|
|
27
|
-
delay: this.options.interval
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
async enqueueBatchJobs(events: EventEntity[]): Promise<void> {
|
|
32
|
-
await this.queue.addBulk(
|
|
33
|
-
events.map((event) => ({
|
|
34
|
-
name: event.id,
|
|
35
|
-
data: event,
|
|
36
|
-
opts: {
|
|
37
|
-
attempts: this.options.retries,
|
|
38
|
-
backoff: {
|
|
39
|
-
type: this.options.backoffType,
|
|
40
|
-
delay: this.options.interval
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}))
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bullMqWorker.producer';
|
package/lib/eject/types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bullMqWorker.types';
|
package/lib/jest.config.d.ts
DELETED
package/lib/jest.config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,QAAA,MAAM,UAAU,EAAE,oBAiBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/lib/jest.config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const jestConfig = {
|
|
2
|
-
preset: 'ts-jest/presets/default-esm', // or other ESM presets
|
|
3
|
-
moduleNameMapper: {
|
|
4
|
-
'^(\\.{1,2}/.*)\\.js$': '$1'
|
|
5
|
-
},
|
|
6
|
-
transform: {
|
|
7
|
-
// '^.+\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`
|
|
8
|
-
// '^.+\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`
|
|
9
|
-
'^.+\\.[tj]sx?$': [
|
|
10
|
-
'ts-jest',
|
|
11
|
-
{
|
|
12
|
-
useESM: true
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
'^.+\\.js$': 'babel-jest'
|
|
16
|
-
},
|
|
17
|
-
testPathIgnorePatterns: ['.*dist/', '.*node_modules/']
|
|
18
|
-
};
|
|
19
|
-
export default jestConfig;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { WorkerProducer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import { WorkerEventEntity } from '@forklaunch/interfaces-worker/types';
|
|
3
|
-
import { BullMqWorkerOptions } from '../types/bullMqWorker.types';
|
|
4
|
-
export declare class BullMqWorkerProducer<
|
|
5
|
-
EventEntity extends WorkerEventEntity,
|
|
6
|
-
Options extends BullMqWorkerOptions
|
|
7
|
-
> implements WorkerProducer<EventEntity>
|
|
8
|
-
{
|
|
9
|
-
private readonly queueName;
|
|
10
|
-
private readonly options;
|
|
11
|
-
private queue;
|
|
12
|
-
constructor(queueName: string, options: Options);
|
|
13
|
-
enqueueJob(event: EventEntity): Promise<void>;
|
|
14
|
-
enqueueBatchJobs(events: EventEntity[]): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=bullMqWorker.producer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bullMqWorker.producer.d.ts","sourceRoot":"","sources":["../../producers/bullMqWorker.producer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,qBAAa,oBAAoB,CAC/B,WAAW,SAAS,iBAAiB,EACrC,OAAO,SAAS,mBAAmB,CACnC,YAAW,cAAc,CAAC,WAAW,CAAC;IAKpC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,KAAK,CAAC;gBAGK,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO;IAO7B,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAe7D"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Queue } from 'bullmq';
|
|
2
|
-
export class BullMqWorkerProducer {
|
|
3
|
-
queueName;
|
|
4
|
-
options;
|
|
5
|
-
queue;
|
|
6
|
-
constructor(queueName, options) {
|
|
7
|
-
this.queueName = queueName;
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.queue = new Queue(this.queueName, {
|
|
10
|
-
connection: this.options.connection
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
async enqueueJob(event) {
|
|
14
|
-
await this.queue.add(event.id, event, {
|
|
15
|
-
attempts: this.options.retries,
|
|
16
|
-
backoff: {
|
|
17
|
-
type: this.options.backoffType,
|
|
18
|
-
delay: this.options.interval
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
async enqueueBatchJobs(events) {
|
|
23
|
-
await this.queue.addBulk(
|
|
24
|
-
events.map((event) => ({
|
|
25
|
-
name: event.id,
|
|
26
|
-
data: event,
|
|
27
|
-
opts: {
|
|
28
|
-
attempts: this.options.retries,
|
|
29
|
-
backoff: {
|
|
30
|
-
type: this.options.backoffType,
|
|
31
|
-
delay: this.options.interval
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}))
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
package/lib/producers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/lib/producers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bullMqWorker.producer';
|