@falcondev-oss/workflow 0.6.1 → 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 +8 -1
- package/dist/index.mjs +17 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -89,7 +89,14 @@ 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
|
+
};
|
|
99
|
+
workerOptions?: SetOptional<WorkerOptions, 'connection'>;
|
|
93
100
|
queueEventsOptions?: SetOptional<QueueEventsOptions, 'connection'>;
|
|
94
101
|
connection?: ConnectionOptions;
|
|
95
102
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -246,6 +246,7 @@ var Workflow = class {
|
|
|
246
246
|
}, {
|
|
247
247
|
connection: this.opts.connection ?? await defaultRedisConnection(),
|
|
248
248
|
prefix: Settings.defaultPrefix,
|
|
249
|
+
...this.opts.workerOptions,
|
|
249
250
|
...opts
|
|
250
251
|
});
|
|
251
252
|
await worker.waitUntilReady();
|
|
@@ -313,16 +314,22 @@ var Workflow = class {
|
|
|
313
314
|
});
|
|
314
315
|
}
|
|
315
316
|
async getOrCreateQueue() {
|
|
316
|
-
if (!this.queue)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
+
}
|
|
326
333
|
await this.queue.waitUntilReady();
|
|
327
334
|
return this.queue;
|
|
328
335
|
}
|
package/package.json
CHANGED