UNPKG

@mastra/core

Version:
15 lines • 958 B
export declare const DEFAULT_RESTART_CONCURRENCY = 5; export declare function normalizeConcurrency(value: number | undefined): number; /** * Run `task` over `items` with at most `limit` in flight. Resolves once every * task has settled; `task` is expected to handle its own errors. */ export declare function runWithConcurrency<T>(items: readonly T[], limit: number | undefined, task: (item: T) => Promise<void>): Promise<void>; /** A concurrency limit shared by tasks that arrive over time, such as every recovery pass's restarts on one instance. */ export interface ConcurrencyLimiter { /** Queues `task` until a slot is free, in arrival order, and settles as it does. */ run<T>(task: () => Promise<T>): Promise<T>; } /** Creates a {@link ConcurrencyLimiter} with at most `limit` tasks running. */ export declare function createConcurrencyLimiter(limit: number | undefined): ConcurrencyLimiter; //# sourceMappingURL=run-with-concurrency.d.ts.map