UNPKG

@codeplaydata/datasus

Version:

This application decompress the datasus micro data and serve as a gateway class.

43 lines (42 loc) 2.14 kB
import { Command } from "../Command.js"; import { JobMessage } from "./JobMessage.js"; import { Parser } from "../../interface/utils/Parser.js"; import { Records } from "../../core/Records.js"; import { DataSource } from "../../core/Datasource.js"; /** * Schedules and orchestrates the execution of jobs (child processes) over a chunk of files. * * It recursively schedules executions until the chunk is fully processed, forwarding * criteria, output options, and optional callback/parser to the JobRunner. */ export declare class JobScheduler<D extends DataSource> implements Command { readonly MAX_CONCURRENT_PROCESSES: number; readonly criteria?: Map<string, string | string[]> | undefined; readonly DATA_PATH?: string | undefined; private filesProcessed; /** * @param MAX_CONCURRENT_PROCESSES Unused here but kept for API symmetry with orchestrator. * @param criteria Optional criteria applied by JobProcessor when filtering records. * @param DATA_PATH Base path used by children to read/write data files. */ private constructor(); /** * Factory method to create a scheduler. */ static init(MAX_CONCURRENT_PROCESSES?: number, criteria?: Map<string, string | string[]>, DATA_PATH?: string): JobScheduler<DataSource>; /** * Increments the internal counter of processed files. * @param qnt How many files to add (default 1). */ incrementFilesProcessed(qnt?: number): number; /** * Executes the scheduling cycle for the given chunk. * @param chunk List of files (or messages) to process. * @param output Output destination of child processing ('stdout' | 'file'). * @param jobScript Path to the worker script to fork. * @param dataSource Optional dataset identifier, forwarded to child. * @param callback Optional callback invoked for each processed record. * @param parser Optional parser to transform each emitted record. */ exec(chunk: string[] | JobMessage[], output: "stdout" | "file" | undefined, jobScript: string, dataSource?: D, callback?: Function, parser?: Parser<Records>): Promise<void>; }