@overture-stack/lyric
Version:
Data Submission system
31 lines (30 loc) • 1.22 kB
TypeScript
import * as workerpool from 'workerpool';
import type { AppConfig } from '../config/config.js';
import type { WorkerFunctions } from './types.js';
/**
* Worker pool configuration values used to initialize `workerpool.pool`.
*/
export type WorkerPoolConfig = {
/** Absolute path to the worker entry file. */
workerPath: string;
/** Optional worker pool runtime options. */
poolOptions?: Parameters<typeof workerpool.pool>[1];
};
/**
* Resolves worker pool configuration at runtime.
*/
export type WorkerPoolConfigResolver = () => WorkerPoolConfig;
/**
* Optional overrides used when creating a worker pool.
*/
export type CreateWorkerPoolOptions = {
/** Custom resolver, primarily used by tests to inject worker settings. */
resolveWorkerPoolConfig?: WorkerPoolConfigResolver;
};
/**
* Factory function to create a worker pool with the given configuration.
* @param configData The application configuration
* @param options Optional worker pool customization (used by tests to inject TS workers).
* @returns The worker functions to execute tasks in the worker pool
*/
export declare const createWorkerPool: (configData: AppConfig, options?: CreateWorkerPoolOptions) => WorkerFunctions;