@forklaunch/implementation-worker-bullmq 0.5.8 → 0.6.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/lib/consumers/index.d.mts +12 -25
- package/lib/consumers/index.d.ts +12 -25
- package/lib/consumers/index.js +10 -15
- package/lib/consumers/index.mjs +6 -4
- package/lib/domain/schemas/index.d.mts +10 -56
- package/lib/domain/schemas/index.d.ts +10 -56
- package/lib/domain/schemas/index.js +539 -581
- package/lib/domain/schemas/index.mjs +543 -545
- package/lib/domain/types/index.d.mts +4 -4
- package/lib/domain/types/index.d.ts +4 -4
- package/lib/domain/types/index.js +4 -8
- package/lib/producers/index.d.mts +7 -11
- package/lib/producers/index.d.ts +7 -11
- package/lib/producers/index.js +8 -13
- package/lib/producers/index.mjs +4 -2
- package/package.json +8 -8
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
3
|
-
WorkerEventEntity,
|
|
4
|
-
WorkerProcessFunction,
|
|
5
|
-
WorkerFailureHandler
|
|
6
|
-
} from '@forklaunch/interfaces-worker/types';
|
|
2
|
+
import { WorkerEventEntity, WorkerProcessFunction, WorkerFailureHandler } from '@forklaunch/interfaces-worker/types';
|
|
7
3
|
import { BullMqWorkerOptions } from '../domain/types/index.mjs';
|
|
8
4
|
import 'bullmq';
|
|
9
5
|
|
|
10
|
-
declare class BullMqWorkerConsumer<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
queueName: string,
|
|
23
|
-
options: Options,
|
|
24
|
-
processEvents: WorkerProcessFunction<EventEntity>,
|
|
25
|
-
failureHandler: WorkerFailureHandler<EventEntity>
|
|
26
|
-
);
|
|
27
|
-
peekEvents(): Promise<EventEntity[]>;
|
|
28
|
-
start(): Promise<void>;
|
|
29
|
-
close(): Promise<void>;
|
|
6
|
+
declare class BullMqWorkerConsumer<EventEntity extends WorkerEventEntity, Options extends BullMqWorkerOptions> implements WorkerConsumer<EventEntity> {
|
|
7
|
+
private queue;
|
|
8
|
+
private worker?;
|
|
9
|
+
protected readonly queueName: string;
|
|
10
|
+
protected readonly options: Options;
|
|
11
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
12
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
13
|
+
constructor(queueName: string, options: Options, processEvents: WorkerProcessFunction<EventEntity>, failureHandler: WorkerFailureHandler<EventEntity>);
|
|
14
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
30
17
|
}
|
|
31
18
|
|
|
32
19
|
export { BullMqWorkerConsumer };
|
package/lib/consumers/index.d.ts
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
2
|
-
import {
|
|
3
|
-
WorkerEventEntity,
|
|
4
|
-
WorkerProcessFunction,
|
|
5
|
-
WorkerFailureHandler
|
|
6
|
-
} from '@forklaunch/interfaces-worker/types';
|
|
2
|
+
import { WorkerEventEntity, WorkerProcessFunction, WorkerFailureHandler } from '@forklaunch/interfaces-worker/types';
|
|
7
3
|
import { BullMqWorkerOptions } from '../domain/types/index.js';
|
|
8
4
|
import 'bullmq';
|
|
9
5
|
|
|
10
|
-
declare class BullMqWorkerConsumer<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
queueName: string,
|
|
23
|
-
options: Options,
|
|
24
|
-
processEvents: WorkerProcessFunction<EventEntity>,
|
|
25
|
-
failureHandler: WorkerFailureHandler<EventEntity>
|
|
26
|
-
);
|
|
27
|
-
peekEvents(): Promise<EventEntity[]>;
|
|
28
|
-
start(): Promise<void>;
|
|
29
|
-
close(): Promise<void>;
|
|
6
|
+
declare class BullMqWorkerConsumer<EventEntity extends WorkerEventEntity, Options extends BullMqWorkerOptions> implements WorkerConsumer<EventEntity> {
|
|
7
|
+
private queue;
|
|
8
|
+
private worker?;
|
|
9
|
+
protected readonly queueName: string;
|
|
10
|
+
protected readonly options: Options;
|
|
11
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
12
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
13
|
+
constructor(queueName: string, options: Options, processEvents: WorkerProcessFunction<EventEntity>, failureHandler: WorkerFailureHandler<EventEntity>);
|
|
14
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
30
17
|
}
|
|
31
18
|
|
|
32
19
|
export { BullMqWorkerConsumer };
|
package/lib/consumers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -8,18 +8,14 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// consumers/index.ts
|
|
25
21
|
var consumers_exports = {};
|
|
@@ -29,7 +25,7 @@ __export(consumers_exports, {
|
|
|
29
25
|
module.exports = __toCommonJS(consumers_exports);
|
|
30
26
|
|
|
31
27
|
// consumers/bullMqWorker.consumer.ts
|
|
32
|
-
var import_bullmq = require(
|
|
28
|
+
var import_bullmq = require("bullmq");
|
|
33
29
|
var BullMqWorkerConsumer = class {
|
|
34
30
|
queue;
|
|
35
31
|
worker;
|
|
@@ -47,7 +43,7 @@ var BullMqWorkerConsumer = class {
|
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
async peekEvents() {
|
|
50
|
-
const jobs = await this.queue.getJobs([
|
|
46
|
+
const jobs = await this.queue.getJobs(["waiting", "active"]);
|
|
51
47
|
return jobs.map((job) => job.data);
|
|
52
48
|
}
|
|
53
49
|
async start() {
|
|
@@ -59,7 +55,7 @@ var BullMqWorkerConsumer = class {
|
|
|
59
55
|
},
|
|
60
56
|
this.options.queueOptions
|
|
61
57
|
);
|
|
62
|
-
this.worker.on(
|
|
58
|
+
this.worker.on("failed", (job, error) => {
|
|
63
59
|
if (job) {
|
|
64
60
|
this.failureHandler([
|
|
65
61
|
{
|
|
@@ -76,7 +72,6 @@ var BullMqWorkerConsumer = class {
|
|
|
76
72
|
}
|
|
77
73
|
};
|
|
78
74
|
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
-
0 &&
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
BullMqWorkerConsumer
|
|
77
|
+
});
|
package/lib/consumers/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// consumers/bullMqWorker.consumer.ts
|
|
2
|
-
import { Queue, Worker } from
|
|
2
|
+
import { Queue, Worker } from "bullmq";
|
|
3
3
|
var BullMqWorkerConsumer = class {
|
|
4
4
|
queue;
|
|
5
5
|
worker;
|
|
@@ -17,7 +17,7 @@ var BullMqWorkerConsumer = class {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
async peekEvents() {
|
|
20
|
-
const jobs = await this.queue.getJobs([
|
|
20
|
+
const jobs = await this.queue.getJobs(["waiting", "active"]);
|
|
21
21
|
return jobs.map((job) => job.data);
|
|
22
22
|
}
|
|
23
23
|
async start() {
|
|
@@ -29,7 +29,7 @@ var BullMqWorkerConsumer = class {
|
|
|
29
29
|
},
|
|
30
30
|
this.options.queueOptions
|
|
31
31
|
);
|
|
32
|
-
this.worker.on(
|
|
32
|
+
this.worker.on("failed", (job, error) => {
|
|
33
33
|
if (job) {
|
|
34
34
|
this.failureHandler([
|
|
35
35
|
{
|
|
@@ -45,4 +45,6 @@ var BullMqWorkerConsumer = class {
|
|
|
45
45
|
await this.queue.close();
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
export {
|
|
48
|
+
export {
|
|
49
|
+
BullMqWorkerConsumer
|
|
50
|
+
};
|
|
@@ -4,64 +4,18 @@ import * as bullmq from 'bullmq';
|
|
|
4
4
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
5
5
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
6
6
|
|
|
7
|
-
declare const BullMqWorkerSchemas: <
|
|
8
|
-
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
9
|
-
>(
|
|
10
|
-
options: Record<string, unknown> & {
|
|
7
|
+
declare const BullMqWorkerSchemas: <SchemaValidator extends _forklaunch_validator.AnySchemaValidator>(options: Record<string, unknown> & {
|
|
11
8
|
validator: SchemaValidator;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
>;
|
|
20
|
-
backoffType: _sinclair_typebox.TUnion<
|
|
21
|
-
[
|
|
22
|
-
_sinclair_typebox.TLiteral<'exponential'>,
|
|
23
|
-
_sinclair_typebox.TLiteral<'fixed'>
|
|
24
|
-
]
|
|
25
|
-
>;
|
|
26
|
-
retries: _sinclair_typebox.TTransform<
|
|
27
|
-
_sinclair_typebox.TUnion<
|
|
28
|
-
[
|
|
29
|
-
_sinclair_typebox.TNumber,
|
|
30
|
-
_sinclair_typebox.TString,
|
|
31
|
-
_sinclair_typebox.TBoolean,
|
|
32
|
-
_sinclair_typebox.TNull,
|
|
33
|
-
_sinclair_typebox.TBigInt,
|
|
34
|
-
_sinclair_typebox.TDate
|
|
35
|
-
]
|
|
36
|
-
>,
|
|
37
|
-
number
|
|
38
|
-
>;
|
|
39
|
-
interval: _sinclair_typebox.TTransform<
|
|
40
|
-
_sinclair_typebox.TUnion<
|
|
41
|
-
[
|
|
42
|
-
_sinclair_typebox.TNumber,
|
|
43
|
-
_sinclair_typebox.TString,
|
|
44
|
-
_sinclair_typebox.TBoolean,
|
|
45
|
-
_sinclair_typebox.TNull,
|
|
46
|
-
_sinclair_typebox.TBigInt,
|
|
47
|
-
_sinclair_typebox.TDate
|
|
48
|
-
]
|
|
49
|
-
>,
|
|
50
|
-
number
|
|
51
|
-
>;
|
|
52
|
-
},
|
|
53
|
-
(options: Record<string, unknown>) => {
|
|
54
|
-
queueOptions: zod_v3.ZodType<
|
|
55
|
-
bullmq.QueueOptions,
|
|
56
|
-
zod_v3.ZodTypeDef,
|
|
57
|
-
bullmq.QueueOptions
|
|
58
|
-
>;
|
|
59
|
-
backoffType: zod_v3.ZodUnion<
|
|
60
|
-
[zod_v3.ZodLiteral<'exponential'>, zod_v3.ZodLiteral<'fixed'>]
|
|
61
|
-
>;
|
|
9
|
+
}) => _forklaunch_internal.SchemasByValidator<SchemaValidator, (options: Record<string, unknown>) => {
|
|
10
|
+
queueOptions: _sinclair_typebox.TTransform<_sinclair_typebox.TAny, bullmq.QueueOptions>;
|
|
11
|
+
backoffType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"exponential">, _sinclair_typebox.TLiteral<"fixed">]>;
|
|
12
|
+
retries: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
13
|
+
interval: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
14
|
+
}, (options: Record<string, unknown>) => {
|
|
15
|
+
queueOptions: zod_v3.ZodType<bullmq.QueueOptions, zod_v3.ZodTypeDef, bullmq.QueueOptions>;
|
|
16
|
+
backoffType: zod_v3.ZodUnion<[zod_v3.ZodLiteral<"exponential">, zod_v3.ZodLiteral<"fixed">]>;
|
|
62
17
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
63
18
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
64
|
-
|
|
65
|
-
>;
|
|
19
|
+
}>;
|
|
66
20
|
|
|
67
21
|
export { BullMqWorkerSchemas };
|
|
@@ -4,64 +4,18 @@ import * as bullmq from 'bullmq';
|
|
|
4
4
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
5
5
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
6
6
|
|
|
7
|
-
declare const BullMqWorkerSchemas: <
|
|
8
|
-
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
9
|
-
>(
|
|
10
|
-
options: Record<string, unknown> & {
|
|
7
|
+
declare const BullMqWorkerSchemas: <SchemaValidator extends _forklaunch_validator.AnySchemaValidator>(options: Record<string, unknown> & {
|
|
11
8
|
validator: SchemaValidator;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
>;
|
|
20
|
-
backoffType: _sinclair_typebox.TUnion<
|
|
21
|
-
[
|
|
22
|
-
_sinclair_typebox.TLiteral<'exponential'>,
|
|
23
|
-
_sinclair_typebox.TLiteral<'fixed'>
|
|
24
|
-
]
|
|
25
|
-
>;
|
|
26
|
-
retries: _sinclair_typebox.TTransform<
|
|
27
|
-
_sinclair_typebox.TUnion<
|
|
28
|
-
[
|
|
29
|
-
_sinclair_typebox.TNumber,
|
|
30
|
-
_sinclair_typebox.TString,
|
|
31
|
-
_sinclair_typebox.TBoolean,
|
|
32
|
-
_sinclair_typebox.TNull,
|
|
33
|
-
_sinclair_typebox.TBigInt,
|
|
34
|
-
_sinclair_typebox.TDate
|
|
35
|
-
]
|
|
36
|
-
>,
|
|
37
|
-
number
|
|
38
|
-
>;
|
|
39
|
-
interval: _sinclair_typebox.TTransform<
|
|
40
|
-
_sinclair_typebox.TUnion<
|
|
41
|
-
[
|
|
42
|
-
_sinclair_typebox.TNumber,
|
|
43
|
-
_sinclair_typebox.TString,
|
|
44
|
-
_sinclair_typebox.TBoolean,
|
|
45
|
-
_sinclair_typebox.TNull,
|
|
46
|
-
_sinclair_typebox.TBigInt,
|
|
47
|
-
_sinclair_typebox.TDate
|
|
48
|
-
]
|
|
49
|
-
>,
|
|
50
|
-
number
|
|
51
|
-
>;
|
|
52
|
-
},
|
|
53
|
-
(options: Record<string, unknown>) => {
|
|
54
|
-
queueOptions: zod_v3.ZodType<
|
|
55
|
-
bullmq.QueueOptions,
|
|
56
|
-
zod_v3.ZodTypeDef,
|
|
57
|
-
bullmq.QueueOptions
|
|
58
|
-
>;
|
|
59
|
-
backoffType: zod_v3.ZodUnion<
|
|
60
|
-
[zod_v3.ZodLiteral<'exponential'>, zod_v3.ZodLiteral<'fixed'>]
|
|
61
|
-
>;
|
|
9
|
+
}) => _forklaunch_internal.SchemasByValidator<SchemaValidator, (options: Record<string, unknown>) => {
|
|
10
|
+
queueOptions: _sinclair_typebox.TTransform<_sinclair_typebox.TAny, bullmq.QueueOptions>;
|
|
11
|
+
backoffType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"exponential">, _sinclair_typebox.TLiteral<"fixed">]>;
|
|
12
|
+
retries: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
13
|
+
interval: _sinclair_typebox.TTransform<_sinclair_typebox.TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TBigInt, _sinclair_typebox.TDate]>, number>;
|
|
14
|
+
}, (options: Record<string, unknown>) => {
|
|
15
|
+
queueOptions: zod_v3.ZodType<bullmq.QueueOptions, zod_v3.ZodTypeDef, bullmq.QueueOptions>;
|
|
16
|
+
backoffType: zod_v3.ZodUnion<[zod_v3.ZodLiteral<"exponential">, zod_v3.ZodLiteral<"fixed">]>;
|
|
62
17
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
63
18
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
64
|
-
|
|
65
|
-
>;
|
|
19
|
+
}>;
|
|
66
20
|
|
|
67
21
|
export { BullMqWorkerSchemas };
|