@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 +7 -1
- package/dist/index.mjs +16 -10
- package/package.json +1 -1
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)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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