UNPKG

@ganache/utils

Version:
62 lines 2.07 kB
import { OverloadedParameters } from "../types"; type RejectableTask = { execute: (...args: any) => Promise<any>; reject: (reason?: any) => void; }; /** * Responsible for managing global concurrent requests. */ export declare class RequestCoordinator { #private; /** * The number of concurrent requests. Set to null for no limit. */ limit: number; /** * The pending requests. You can't do anything with this array. */ readonly pending: RejectableTask[]; /** * The number of tasks currently being processed. */ runningTasks: number; get paused(): boolean; /** * Promise-based FIFO queue. * @param limit - The number of requests that can be processed at a time. * Default value is is no limit (`0`). */ constructor(limit: number); /** * Pause processing. This will *not* cancel any promises that are currently * running. */ pause: () => void; /** * Resume processing. */ resume: () => void; /** * Stop processing tasks - calls to queue(), and resume() will reject with an * error indicating that Ganache is disconnected. This is an irreversible * action. If you wish to be able to resume processing, use pause() instead. * * Note: this changes the references of this.resume and this.queue. Any code * that maintains references to the values referenced by this.resume or * this.queue, could have unintended consequences after calling this.stop(). */ stop(): void; /** * Finalise shutdown of the RequestCoordinator. Rejects all pending tasks in order. Should be * called after all in-flight tasks have resolved in order to maintain overall FIFO order. */ end(): void; /** * Insert a new function into the queue. */ queue: <T extends (...args: unknown[]) => unknown>(fn: T, thisArgument: any, argumentsList: OverloadedParameters<T>) => Promise<{ value: ReturnType<T>; }>; } export {}; //# sourceMappingURL=request-coordinator.d.ts.map