@falcondev-oss/workflow 0.6.2 → 0.6.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/dist/index.d.mts CHANGED
@@ -89,7 +89,13 @@ interface WorkflowOptions<RunInput, Input, Output> {
89
89
  id: string;
90
90
  schema?: StandardSchemaV1<RunInput, Input>;
91
91
  run: (ctx: WorkflowRunContext<Input>) => Promise<Output>;
92
- queueOptions?: SetOptional<QueueOptions, 'connection'>;
92
+ queueOptions?: SetOptional<QueueOptions, 'connection'> & {
93
+ globalConcurrency?: number;
94
+ globalRateLimit?: {
95
+ max: number;
96
+ duration: number;
97
+ };
98
+ };
93
99
  workerOptions?: SetOptional<WorkerOptions, 'connection'>;
94
100
  queueEventsOptions?: SetOptional<QueueEventsOptions, 'connection'>;
95
101
  connection?: ConnectionOptions;
package/dist/index.mjs CHANGED
@@ -314,16 +314,22 @@ var Workflow = class {
314
314
  });
315
315
  }
316
316
  async getOrCreateQueue() {
317
- if (!this.queue) this.queue = new Queue(this.opts.id, {
318
- prefix: Settings.defaultPrefix,
319
- connection: this.opts.connection ?? await defaultRedisConnection(),
320
- defaultJobOptions: {
321
- removeOnComplete: true,
322
- removeOnFail: { age: 1440 * 60 },
323
- ...this.opts.queueOptions?.defaultJobOptions
324
- },
325
- ...this.opts.queueOptions
326
- });
317
+ if (!this.queue) {
318
+ this.queue = new Queue(this.opts.id, {
319
+ prefix: Settings.defaultPrefix,
320
+ connection: this.opts.connection ?? await defaultRedisConnection(),
321
+ defaultJobOptions: {
322
+ removeOnComplete: true,
323
+ removeOnFail: { age: 1440 * 60 },
324
+ ...this.opts.queueOptions?.defaultJobOptions
325
+ },
326
+ ...this.opts.queueOptions
327
+ });
328
+ if (this.opts.queueOptions?.globalConcurrency) await this.queue.setGlobalConcurrency(this.opts.queueOptions.globalConcurrency);
329
+ else await this.queue.removeGlobalConcurrency();
330
+ if (this.opts.queueOptions?.globalRateLimit) await this.queue.setGlobalRateLimit(this.opts.queueOptions.globalRateLimit.max, this.opts.queueOptions.globalRateLimit.duration);
331
+ else await this.queue.removeGlobalRateLimit();
332
+ }
327
333
  await this.queue.waitUntilReady();
328
334
  return this.queue;
329
335
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@falcondev-oss/workflow",
3
3
  "type": "module",
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
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",