重构任务并发执行逻辑

This commit is contained in:
whyour
2023-05-30 16:32:00 +08:00
parent 86e3d8736b
commit f8dfee8945
11 changed files with 285 additions and 236 deletions
+10
View File
@@ -0,0 +1,10 @@
import pLimit from "p-limit";
import os from 'os';
const cronLimit = pLimit(os.cpus.length);
export function runCronWithLimit<T>(fn: () => Promise<T>): Promise<T> {
return cronLimit(() => {
return fn();
});
}