@forklaunch/implementation-worker-redis 0.6.3 → 0.6.4
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 +26 -12
- package/lib/consumers/index.d.ts +26 -12
- package/lib/consumers/index.js +24 -15
- package/lib/consumers/index.mjs +13 -11
- package/lib/domain/schemas/index.d.mts +51 -7
- package/lib/domain/schemas/index.d.ts +51 -7
- package/lib/domain/schemas/index.js +579 -537
- package/lib/domain/schemas/index.mjs +543 -541
- package/lib/domain/types/index.d.mts +3 -3
- package/lib/domain/types/index.d.ts +3 -3
- package/lib/domain/types/index.js +8 -4
- package/lib/producers/index.d.mts +11 -7
- package/lib/producers/index.d.ts +11 -7
- package/lib/producers/index.js +12 -7
- package/lib/producers/index.mjs +1 -3
- package/package.json +6 -6
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { TtlCache } from '@forklaunch/core/cache';
|
|
2
2
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
WorkerEventEntity,
|
|
5
|
+
WorkerProcessFunction,
|
|
6
|
+
WorkerFailureHandler
|
|
7
|
+
} from '@forklaunch/interfaces-worker/types';
|
|
4
8
|
import { RedisWorkerOptions } from '../domain/types/index.mjs';
|
|
5
9
|
|
|
6
|
-
declare class RedisWorkerConsumer<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
declare class RedisWorkerConsumer<
|
|
11
|
+
EventEntity extends WorkerEventEntity,
|
|
12
|
+
Options extends RedisWorkerOptions
|
|
13
|
+
> implements WorkerConsumer<EventEntity>
|
|
14
|
+
{
|
|
15
|
+
protected readonly queueName: string;
|
|
16
|
+
protected readonly cache: TtlCache;
|
|
17
|
+
protected readonly options: Options;
|
|
18
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
19
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
20
|
+
constructor(
|
|
21
|
+
queueName: string,
|
|
22
|
+
cache: TtlCache,
|
|
23
|
+
options: Options,
|
|
24
|
+
processEvents: WorkerProcessFunction<EventEntity>,
|
|
25
|
+
failureHandler: WorkerFailureHandler<EventEntity>
|
|
26
|
+
);
|
|
27
|
+
private retrieveEvents;
|
|
28
|
+
private updateEvents;
|
|
29
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
30
|
+
start(): Promise<void>;
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
export { RedisWorkerConsumer };
|
package/lib/consumers/index.d.ts
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { TtlCache } from '@forklaunch/core/cache';
|
|
2
2
|
import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
WorkerEventEntity,
|
|
5
|
+
WorkerProcessFunction,
|
|
6
|
+
WorkerFailureHandler
|
|
7
|
+
} from '@forklaunch/interfaces-worker/types';
|
|
4
8
|
import { RedisWorkerOptions } from '../domain/types/index.js';
|
|
5
9
|
|
|
6
|
-
declare class RedisWorkerConsumer<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
declare class RedisWorkerConsumer<
|
|
11
|
+
EventEntity extends WorkerEventEntity,
|
|
12
|
+
Options extends RedisWorkerOptions
|
|
13
|
+
> implements WorkerConsumer<EventEntity>
|
|
14
|
+
{
|
|
15
|
+
protected readonly queueName: string;
|
|
16
|
+
protected readonly cache: TtlCache;
|
|
17
|
+
protected readonly options: Options;
|
|
18
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
19
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
20
|
+
constructor(
|
|
21
|
+
queueName: string,
|
|
22
|
+
cache: TtlCache,
|
|
23
|
+
options: Options,
|
|
24
|
+
processEvents: WorkerProcessFunction<EventEntity>,
|
|
25
|
+
failureHandler: WorkerFailureHandler<EventEntity>
|
|
26
|
+
);
|
|
27
|
+
private retrieveEvents;
|
|
28
|
+
private updateEvents;
|
|
29
|
+
peekEvents(): Promise<EventEntity[]>;
|
|
30
|
+
start(): Promise<void>;
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
export { RedisWorkerConsumer };
|
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,14 +8,18 @@ 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 (from && typeof from ===
|
|
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, {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
18
|
-
var __toCommonJS = (mod) =>
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
19
23
|
|
|
20
24
|
// consumers/index.ts
|
|
21
25
|
var consumers_exports = {};
|
|
@@ -39,19 +43,23 @@ var RedisWorkerConsumer = class {
|
|
|
39
43
|
this.failureHandler = failureHandler;
|
|
40
44
|
}
|
|
41
45
|
async retrieveEvents() {
|
|
42
|
-
const events = (
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
const events = (
|
|
47
|
+
await this.cache.dequeueBatchRecords(
|
|
48
|
+
this.queueName,
|
|
49
|
+
this.options.pageSize
|
|
50
|
+
)
|
|
51
|
+
).filter((event) => event != null);
|
|
46
52
|
return events;
|
|
47
53
|
}
|
|
48
54
|
async updateEvents(events) {
|
|
49
55
|
await this.cache.enqueueBatchRecords(
|
|
50
56
|
this.queueName,
|
|
51
|
-
events
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
events
|
|
58
|
+
.filter((event) => event != null && event.retryCount <= 3)
|
|
59
|
+
.map((event) => ({
|
|
60
|
+
...event,
|
|
61
|
+
retryCount: event.retryCount + 1
|
|
62
|
+
}))
|
|
55
63
|
);
|
|
56
64
|
}
|
|
57
65
|
async peekEvents() {
|
|
@@ -71,6 +79,7 @@ var RedisWorkerConsumer = class {
|
|
|
71
79
|
}
|
|
72
80
|
};
|
|
73
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 &&
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
0 &&
|
|
83
|
+
(module.exports = {
|
|
84
|
+
RedisWorkerConsumer
|
|
85
|
+
});
|
package/lib/consumers/index.mjs
CHANGED
|
@@ -13,19 +13,23 @@ var RedisWorkerConsumer = class {
|
|
|
13
13
|
this.failureHandler = failureHandler;
|
|
14
14
|
}
|
|
15
15
|
async retrieveEvents() {
|
|
16
|
-
const events = (
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const events = (
|
|
17
|
+
await this.cache.dequeueBatchRecords(
|
|
18
|
+
this.queueName,
|
|
19
|
+
this.options.pageSize
|
|
20
|
+
)
|
|
21
|
+
).filter((event) => event != null);
|
|
20
22
|
return events;
|
|
21
23
|
}
|
|
22
24
|
async updateEvents(events) {
|
|
23
25
|
await this.cache.enqueueBatchRecords(
|
|
24
26
|
this.queueName,
|
|
25
|
-
events
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
events
|
|
28
|
+
.filter((event) => event != null && event.retryCount <= 3)
|
|
29
|
+
.map((event) => ({
|
|
30
|
+
...event,
|
|
31
|
+
retryCount: event.retryCount + 1
|
|
32
|
+
}))
|
|
29
33
|
);
|
|
30
34
|
}
|
|
31
35
|
async peekEvents() {
|
|
@@ -44,6 +48,4 @@ var RedisWorkerConsumer = class {
|
|
|
44
48
|
}, this.options.interval);
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
|
-
export {
|
|
48
|
-
RedisWorkerConsumer
|
|
49
|
-
};
|
|
51
|
+
export { RedisWorkerConsumer };
|
|
@@ -3,16 +3,60 @@ import * as zod_v3 from 'zod/v3';
|
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
5
|
|
|
6
|
-
declare const RedisWorkerSchemas: <
|
|
6
|
+
declare const RedisWorkerSchemas: <
|
|
7
|
+
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
+
>(
|
|
9
|
+
options: Record<string, unknown> & {
|
|
7
10
|
validator: SchemaValidator;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
) => _forklaunch_internal.SchemasByValidator<
|
|
13
|
+
SchemaValidator,
|
|
14
|
+
(options: Record<string, unknown>) => {
|
|
15
|
+
pageSize: _sinclair_typebox.TTransform<
|
|
16
|
+
_sinclair_typebox.TUnion<
|
|
17
|
+
[
|
|
18
|
+
_sinclair_typebox.TNumber,
|
|
19
|
+
_sinclair_typebox.TString,
|
|
20
|
+
_sinclair_typebox.TBoolean,
|
|
21
|
+
_sinclair_typebox.TNull,
|
|
22
|
+
_sinclair_typebox.TBigInt,
|
|
23
|
+
_sinclair_typebox.TDate
|
|
24
|
+
]
|
|
25
|
+
>,
|
|
26
|
+
number
|
|
27
|
+
>;
|
|
28
|
+
retries: _sinclair_typebox.TTransform<
|
|
29
|
+
_sinclair_typebox.TUnion<
|
|
30
|
+
[
|
|
31
|
+
_sinclair_typebox.TNumber,
|
|
32
|
+
_sinclair_typebox.TString,
|
|
33
|
+
_sinclair_typebox.TBoolean,
|
|
34
|
+
_sinclair_typebox.TNull,
|
|
35
|
+
_sinclair_typebox.TBigInt,
|
|
36
|
+
_sinclair_typebox.TDate
|
|
37
|
+
]
|
|
38
|
+
>,
|
|
39
|
+
number
|
|
40
|
+
>;
|
|
41
|
+
interval: _sinclair_typebox.TTransform<
|
|
42
|
+
_sinclair_typebox.TUnion<
|
|
43
|
+
[
|
|
44
|
+
_sinclair_typebox.TNumber,
|
|
45
|
+
_sinclair_typebox.TString,
|
|
46
|
+
_sinclair_typebox.TBoolean,
|
|
47
|
+
_sinclair_typebox.TNull,
|
|
48
|
+
_sinclair_typebox.TBigInt,
|
|
49
|
+
_sinclair_typebox.TDate
|
|
50
|
+
]
|
|
51
|
+
>,
|
|
52
|
+
number
|
|
53
|
+
>;
|
|
54
|
+
},
|
|
55
|
+
(options: Record<string, unknown>) => {
|
|
13
56
|
pageSize: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
14
57
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
15
58
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
16
|
-
}
|
|
59
|
+
}
|
|
60
|
+
>;
|
|
17
61
|
|
|
18
62
|
export { RedisWorkerSchemas };
|
|
@@ -3,16 +3,60 @@ import * as zod_v3 from 'zod/v3';
|
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import * as _forklaunch_validator from '@forklaunch/validator';
|
|
5
5
|
|
|
6
|
-
declare const RedisWorkerSchemas: <
|
|
6
|
+
declare const RedisWorkerSchemas: <
|
|
7
|
+
SchemaValidator extends _forklaunch_validator.AnySchemaValidator
|
|
8
|
+
>(
|
|
9
|
+
options: Record<string, unknown> & {
|
|
7
10
|
validator: SchemaValidator;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
) => _forklaunch_internal.SchemasByValidator<
|
|
13
|
+
SchemaValidator,
|
|
14
|
+
(options: Record<string, unknown>) => {
|
|
15
|
+
pageSize: _sinclair_typebox.TTransform<
|
|
16
|
+
_sinclair_typebox.TUnion<
|
|
17
|
+
[
|
|
18
|
+
_sinclair_typebox.TNumber,
|
|
19
|
+
_sinclair_typebox.TString,
|
|
20
|
+
_sinclair_typebox.TBoolean,
|
|
21
|
+
_sinclair_typebox.TNull,
|
|
22
|
+
_sinclair_typebox.TBigInt,
|
|
23
|
+
_sinclair_typebox.TDate
|
|
24
|
+
]
|
|
25
|
+
>,
|
|
26
|
+
number
|
|
27
|
+
>;
|
|
28
|
+
retries: _sinclair_typebox.TTransform<
|
|
29
|
+
_sinclair_typebox.TUnion<
|
|
30
|
+
[
|
|
31
|
+
_sinclair_typebox.TNumber,
|
|
32
|
+
_sinclair_typebox.TString,
|
|
33
|
+
_sinclair_typebox.TBoolean,
|
|
34
|
+
_sinclair_typebox.TNull,
|
|
35
|
+
_sinclair_typebox.TBigInt,
|
|
36
|
+
_sinclair_typebox.TDate
|
|
37
|
+
]
|
|
38
|
+
>,
|
|
39
|
+
number
|
|
40
|
+
>;
|
|
41
|
+
interval: _sinclair_typebox.TTransform<
|
|
42
|
+
_sinclair_typebox.TUnion<
|
|
43
|
+
[
|
|
44
|
+
_sinclair_typebox.TNumber,
|
|
45
|
+
_sinclair_typebox.TString,
|
|
46
|
+
_sinclair_typebox.TBoolean,
|
|
47
|
+
_sinclair_typebox.TNull,
|
|
48
|
+
_sinclair_typebox.TBigInt,
|
|
49
|
+
_sinclair_typebox.TDate
|
|
50
|
+
]
|
|
51
|
+
>,
|
|
52
|
+
number
|
|
53
|
+
>;
|
|
54
|
+
},
|
|
55
|
+
(options: Record<string, unknown>) => {
|
|
13
56
|
pageSize: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
14
57
|
retries: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
15
58
|
interval: zod_v3.ZodEffects<zod_v3.ZodNumber, number, unknown>;
|
|
16
|
-
}
|
|
59
|
+
}
|
|
60
|
+
>;
|
|
17
61
|
|
|
18
62
|
export { RedisWorkerSchemas };
|