import { Log } from 'ts-tiny-log'; import { WorkerSpawnData } from './worker'; import { ParentThread } from './parent'; import type { QueueCallback, ErrorHandler } from './queue'; export interface WorkerConfig { /** * Function to run on worker startup */ startup: (data: WorkerSpawnData) => Promise; /** * Function to run for the queue task */ callback: QueueCallback; /** * Function to run on error */ error?: ErrorHandler; /** * Class for communicating Worker -> Parent */ parentType: typeof ParentThread; } /** * QueueWorker class - handles task execution on worker threads * * @typeParam TIn Queue task input type * @typeParam TOut Queue task output type */ export declare class QueueWorker { protected log: Log; protected parent: ParentThread; protected config: WorkerConfig; /** * Runs on: Worker * * @param config Worker configuration */ constructor(config: WorkerConfig); /** * Initialize the worker with startup callback * * Runs on: Worker */ initialize(): Promise; /** * Start listening for work from the parent thread * * Runs on: Worker */ protected listenForWork(): void; }