Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Oct 21, 2024
1 parent 5a25312 commit 471b358
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 60 deletions.
1 change: 0 additions & 1 deletion Target/master.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import type { IOptions } from "./protocol.js";

export declare function spawnWorkers(options: IOptions): Promise<void>;
31 changes: 15 additions & 16 deletions Target/progress-reporter.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { type IFormatResults } from "./protocol.js";

/**
* Handles reporting progress of the formatting to the console.
*/
export declare class ProgressReporter {
private readonly check;
total: number;
reformatted: number;
failed: number;
private spinner?;
constructor(quiet: boolean, check: boolean);
/**
* Increments the count of the total and reformatted files.
*/
update(results: IFormatResults): void;
/**
* Prints a completion message.
*/
complete(): void;
private getMessage;
private readonly check;
total: number;
reformatted: number;
failed: number;
private spinner?;
constructor(quiet: boolean, check: boolean);
/**
* Increments the count of the total and reformatted files.
*/
update(results: IFormatResults): void;
/**
* Prints a completion message.
*/
complete(): void;
private getMessage;
}
52 changes: 26 additions & 26 deletions Target/protocol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
* MessageType delimits the kind of message sent in the formatter IPC.
*/
export declare enum MessageType {
WorkerInitialization = 0,
WorkerFiles = 1,
Formatted = 2,
Complete = 3,
WorkerInitialization = 0,
WorkerFiles = 1,
Formatted = 2,
Complete = 3
}
export declare enum WorkerMode {
Write = 0,
Print = 1,
Assert = 2,
Write = 0,
Print = 1,
Assert = 2
}
/**
* An InitializationMessage is sent from
* the master to queue work on its workers.
*/
export interface IInitializationMessage {
type: MessageType.WorkerInitialization;
mode: WorkerMode.Write;
type: MessageType.WorkerInitialization;
mode: WorkerMode.Write;
}
/**
* IFiles is sent to queue files to format on the worker.
*/
export interface IFilesMessage {
type: MessageType.WorkerFiles;
files: IDiscoveredFile[];
id: number;
type: MessageType.WorkerFiles;
files: IDiscoveredFile[];
id: number;
}
/**
* MasterMessage is sent from the cluster master to its workers.
Expand All @@ -36,24 +36,24 @@ export type MasterMessage = IInitializationMessage | IFilesMessage;
* Results returned from formatting files.
*/
export interface IFormatResults {
files: number;
failed: IDiscoveredFile[];
formatted: IDiscoveredFile[];
files: number;
failed: IDiscoveredFile[];
formatted: IDiscoveredFile[];
}
/**
* Format message received from a worker.
*/
export interface IFormattedMessage extends IFormatResults {
type: MessageType.Formatted;
id: number;
type: MessageType.Formatted;
id: number;
}
/**
* Discovered file item.
*/
export interface IDiscoveredFile {
cwd: string;
base: string;
path: string;
cwd: string;
base: string;
path: string;
}
/**
* Mesage is sent from the worker to the parent process.
Expand All @@ -63,10 +63,10 @@ export type WorkerMessage = IFormattedMessage;
* Top-level options for the formatter.
*/
export interface IOptions {
check: boolean;
write: boolean;
concurrency: number;
quiet: boolean;
files: string[];
ignorePath: string;
check: boolean;
write: boolean;
concurrency: number;
quiet: boolean;
files: string[];
ignorePath: string;
}
32 changes: 15 additions & 17 deletions Target/worker-pool.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { Observable } from "rxjs";

import { type IFormatResults, type IOptions } from "./protocol.js";

export declare class WorkerExitedError extends Error {
constructor(codeOrSignal: number | string);
constructor(codeOrSignal: number | string);
}
/**
* Pool of workers.
*/
export declare class WorkerPool {
private readonly options;
private readonly workers;
private workIdCounter;
/**
* Maximum size of the worker pool.
*/
get maxSize(): number;
constructor(options: IOptions);
/**
* Schedules the given files to be formatted.
*/
format(files: string[]): Observable<IFormatResults> | void;
private sortWorkers;
private spawnWorker;
private readonly options;
private readonly workers;
private workIdCounter;
/**
* Maximum size of the worker pool.
*/
get maxSize(): number;
constructor(options: IOptions);
/**
* Schedules the given files to be formatted.
*/
format(files: string[]): Observable<IFormatResults> | void;
private sortWorkers;
private spawnWorker;
}

0 comments on commit 471b358

Please sign in to comment.