@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
31 lines (30 loc) • 995 B
TypeScript
import { TransformOpt, TransformTyped } from '../../stream.model';
export interface TransformMultiThreadedOptions extends TransformOpt {
/**
* Absolute path to a js file with worker code
*/
workerFile: string;
/**
* @default 2, to match CircleCI and Github Actions environments
*/
poolSize?: number;
/**
* @default to poolSize
*/
concurrency?: number;
/**
* @default to Math.max(16, concurrency x 2)
*/
highWaterMark?: number;
/**
* Passed to the Worker as `workerData` property (initial data).
*/
workerData?: object;
}
/**
* Spawns a pool of Workers (threads).
* Distributes (using round-robin, equally) all inputs over Workers.
* Workers emit 1 output for each 1 input.
* Output of Workers is passed down the stream. Order is RANDOM (since it's a multi-threaded environment).
*/
export declare function transformMultiThreaded<IN, OUT>(opt: TransformMultiThreadedOptions): TransformTyped<IN, OUT>;