@forklaunch/implementation-worker-redis 0.5.4 → 0.5.5

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.
@@ -1,19 +1,33 @@
1
1
  import { TtlCache } from '@forklaunch/core/cache';
2
2
  import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
3
- import { WorkerEventEntity, WorkerProcessFunction, WorkerFailureHandler } from '@forklaunch/interfaces-worker/types';
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<EventEntity extends WorkerEventEntity, Options extends RedisWorkerOptions> implements WorkerConsumer<EventEntity> {
7
- protected readonly queueName: string;
8
- protected readonly cache: TtlCache;
9
- protected readonly options: Options;
10
- protected readonly processEvents: WorkerProcessFunction<EventEntity>;
11
- protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
12
- constructor(queueName: string, cache: TtlCache, options: Options, processEvents: WorkerProcessFunction<EventEntity>, failureHandler: WorkerFailureHandler<EventEntity>);
13
- private retrieveEvents;
14
- private updateEvents;
15
- peekEvents(): Promise<EventEntity[]>;
16
- start(): Promise<void>;
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 };
@@ -1,19 +1,33 @@
1
1
  import { TtlCache } from '@forklaunch/core/cache';
2
2
  import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
3
- import { WorkerEventEntity, WorkerProcessFunction, WorkerFailureHandler } from '@forklaunch/interfaces-worker/types';
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<EventEntity extends WorkerEventEntity, Options extends RedisWorkerOptions> implements WorkerConsumer<EventEntity> {
7
- protected readonly queueName: string;
8
- protected readonly cache: TtlCache;
9
- protected readonly options: Options;
10
- protected readonly processEvents: WorkerProcessFunction<EventEntity>;
11
- protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
12
- constructor(queueName: string, cache: TtlCache, options: Options, processEvents: WorkerProcessFunction<EventEntity>, failureHandler: WorkerFailureHandler<EventEntity>);
13
- private retrieveEvents;
14
- private updateEvents;
15
- peekEvents(): Promise<EventEntity[]>;
16
- start(): Promise<void>;
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 };
@@ -1,4 +1,4 @@
1
- "use strict";
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 === "object" || typeof from === "function") {
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, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
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) => __copyProps(__defProp({}, "__esModule", { value: true }), 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 = (await this.cache.dequeueBatchRecords(
43
- this.queueName,
44
- this.options.pageSize
45
- )).filter((event) => event != null);
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.filter((event) => event != null && event.retryCount <= 3).map((event) => ({
52
- ...event,
53
- retryCount: event.retryCount + 1
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 && (module.exports = {
75
- RedisWorkerConsumer
76
- });
82
+ 0 &&
83
+ (module.exports = {
84
+ RedisWorkerConsumer
85
+ });
@@ -13,19 +13,23 @@ var RedisWorkerConsumer = class {
13
13
  this.failureHandler = failureHandler;
14
14
  }
15
15
  async retrieveEvents() {
16
- const events = (await this.cache.dequeueBatchRecords(
17
- this.queueName,
18
- this.options.pageSize
19
- )).filter((event) => event != null);
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.filter((event) => event != null && event.retryCount <= 3).map((event) => ({
26
- ...event,
27
- retryCount: event.retryCount + 1
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: <SchemaValidator extends _forklaunch_validator.AnySchemaValidator>(options: Record<string, unknown> & {
6
+ declare const RedisWorkerSchemas: <
7
+ SchemaValidator extends _forklaunch_validator.AnySchemaValidator
8
+ >(
9
+ options: Record<string, unknown> & {
7
10
  validator: SchemaValidator;
8
- }) => _forklaunch_internal.SchemasByValidator<SchemaValidator, (options: Record<string, unknown>) => {
9
- pageSize: _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>;
10
- 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>;
11
- 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>;
12
- }, (options: Record<string, unknown>) => {
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: <SchemaValidator extends _forklaunch_validator.AnySchemaValidator>(options: Record<string, unknown> & {
6
+ declare const RedisWorkerSchemas: <
7
+ SchemaValidator extends _forklaunch_validator.AnySchemaValidator
8
+ >(
9
+ options: Record<string, unknown> & {
7
10
  validator: SchemaValidator;
8
- }) => _forklaunch_internal.SchemasByValidator<SchemaValidator, (options: Record<string, unknown>) => {
9
- pageSize: _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>;
10
- 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>;
11
- 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>;
12
- }, (options: Record<string, unknown>) => {
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 };