1import { ForkOptions } from "child_process"; 2 3export = Farm; 4 5declare function Farm(name: string): Farm.Workers; 6declare function Farm(name: string, exportedMethods: string[]): Farm.Workers; 7declare function Farm(options: Farm.FarmOptions, name: string): Farm.Workers; 8declare function Farm( 9 options: Farm.FarmOptions, 10 name: string, 11 exportedMethods: string[], 12): Farm.Workers; 13 14type WorkerCallback0 = () => void; 15type WorkerCallback1 = (arg1: any) => void; 16type WorkerCallback2 = (arg1: any, arg2: any) => void; 17type WorkerCallback3 = (arg1: any, arg2: any, arg3: any) => void; 18type WorkerCallback4 = (arg1: any, arg2: any, arg3: any, arg4: any) => void; 19 20declare namespace Farm { 21 export function end(workers: Workers, callback?: Function): void; 22 23 export interface Workers { 24 [x: string]: Workers, 25 (callback: WorkerCallback): void; 26 (arg1: any, callback: WorkerCallback): void; 27 (arg1: any, arg2: any, callback: WorkerCallback): void; 28 (arg1: any, arg2: any, arg3: any, callback: WorkerCallback): void; 29 ( 30 arg1: any, 31 arg2: any, 32 arg3: any, 33 arg4: any, 34 callback: WorkerCallback, 35 ): void; 36 } 37 38 export interface FarmOptions { 39 maxCallsPerWorker?: number; 40 maxConcurrentWorkers?: number; 41 maxConcurrentCallsPerWorker?: number; 42 maxConcurrentCalls?: number; 43 maxCallTime?: number; 44 maxRetries?: number; 45 autoStart?: boolean; 46 workerOptions?: ForkOptions; 47 } 48 49 export type WorkerCallback = 50 | WorkerCallback0 51 | WorkerCallback1 52 | WorkerCallback2 53 | WorkerCallback3 54 | WorkerCallback4; 55} 56