import { UserInfo } from '@memberjunction/core'; import { Transform } from 'node:stream'; export type TransformCallback = Parameters[0]; export type WorkerData, TRecord = Record> = { batch?: Array; context?: TContext; }; export type BatchWorkerOptions> = { /** * The number of records to process in a batch */ batchSize?: number; /** * The path to the worker file used to launch a worker thread */ workerFile?: string; /** * An abitrary context to pass to the worker thread */ workerContext?: TContext; /** * The maximum number of worker threads to run concurrently */ concurrencyLimit?: number; /** * The user context to pass to the worker thread */ contextUser?: UserInfo; /** * The time to delay between api calls **/ delayTimeMS?: number; }; /** * This class processes records in batches using a worker thread. It expects * a worker file that exports a function to process the batch of records. * The stream operates in object mode and emits processed records. */ export declare class BatchWorker, TContext = Record> extends Transform { _batchSize: number; _workerFile: string; _workerContext: TContext | Record; _concurrencyLimit: number; _running: number; _buffer: Array; _queue: Array<() => Promise>; _contextUser: UserInfo | undefined; /** * @param {BatchWorkerOptions} options - Options for the BatchWorker */ constructor(options?: BatchWorkerOptions); /** * Starts the next task in the queue */ _next(): void; /** * Enqueues a task to be processed * @param task - The task to enqueue */ _enqueue(task: () => Promise): void; _transform(chunk: TRecord, encoding: BufferEncoding, callback: TransformCallback): Promise; _flush(callback: TransformCallback): Promise; _processBatchInWorker(batch: Array): Promise; } //# sourceMappingURL=BatchWorker.d.ts.map