@falcondev-oss/workflow 0.6.0 → 0.6.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.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ConnectionOptions, Job, JobSchedulerTemplateOptions, JobsOptions, Queue, QueueEvents, QueueEventsOptions, QueueOptions, UnrecoverableError, WorkerOptions } from "bullmq";
2
2
  import "@antfu/utils";
3
- import IORedis from "ioredis";
3
+ import IORedis, { RedisOptions } from "ioredis";
4
4
  import { Span } from "@opentelemetry/api";
5
5
  import { SuperJSONResult } from "superjson";
6
6
  import { Options } from "p-retry";
@@ -24,6 +24,7 @@ declare const Settings: {
24
24
  defaultCronTimezone: string | undefined;
25
25
  logger: WorkflowLogger | undefined;
26
26
  };
27
+ declare function createRedisConnection(opts: RedisOptions): Promise<IORedis>;
27
28
  //#endregion
28
29
  //#region src/serializer.d.ts
29
30
  type Serialized<T> = Tagged<SuperJSONResult, 'data', T>;
@@ -89,6 +90,7 @@ interface WorkflowOptions<RunInput, Input, Output> {
89
90
  schema?: StandardSchemaV1<RunInput, Input>;
90
91
  run: (ctx: WorkflowRunContext<Input>) => Promise<Output>;
91
92
  queueOptions?: SetOptional<QueueOptions, 'connection'>;
93
+ workerOptions?: SetOptional<WorkerOptions, 'connection'>;
92
94
  queueEventsOptions?: SetOptional<QueueEventsOptions, 'connection'>;
93
95
  connection?: ConnectionOptions;
94
96
  }
@@ -115,4 +117,4 @@ interface WorkflowRunContext<Input> {
115
117
  span: Span;
116
118
  }
117
119
  //#endregion
118
- export { Settings, Workflow, WorkflowInputError, WorkflowOptions, WorkflowRunContext };
120
+ export { Settings, Workflow, WorkflowInputError, WorkflowOptions, WorkflowRunContext, createRedisConnection };
package/dist/index.mjs CHANGED
@@ -36,6 +36,14 @@ const defaultRedisConnection = createSingletonPromise(async () => {
36
36
  await redis.connect();
37
37
  return redis;
38
38
  });
39
+ async function createRedisConnection(opts) {
40
+ const redis = new IORedis({
41
+ ...defaultRedisOptions,
42
+ ...opts
43
+ });
44
+ await redis.connect();
45
+ return redis;
46
+ }
39
47
 
40
48
  //#endregion
41
49
  //#region src/serializer.ts
@@ -238,6 +246,7 @@ var Workflow = class {
238
246
  }, {
239
247
  connection: this.opts.connection ?? await defaultRedisConnection(),
240
248
  prefix: Settings.defaultPrefix,
249
+ ...this.opts.workerOptions,
241
250
  ...opts
242
251
  });
243
252
  await worker.waitUntilReady();
@@ -330,4 +339,4 @@ var Workflow = class {
330
339
  };
331
340
 
332
341
  //#endregion
333
- export { Settings, Workflow, WorkflowInputError };
342
+ export { Settings, Workflow, WorkflowInputError, createRedisConnection };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@falcondev-oss/workflow",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "description": "Simple type-safe queue worker with durable execution based on BullMQ.",
6
6
  "license": "MIT",
7
7
  "repository": "github:falcondev-oss/workflow",