angular/packages/compiler-cli/ngcc/src/execution/cluster/api.ts
Pete Bacon Darwin 39d4016fe9 refactor(ngcc): abstract onTaskCompleted out of executors (#36083)
Moving the definition of the `onTaskCompleted` callback into `mainNgcc()`
allows it to be configured based on options passed in there more easily.
This will be the case when we want to configure whether to log or throw
an error for tasks that failed to be processed successfully.

This commit also creates two new folders and moves the code around a bit
to make it easier to navigate the code§:

* `execution/tasks`: specific helpers such as task completion handlers
* `execution/tasks/queues`: the `TaskQueue` implementations and helpers

PR Close #36083
2020-03-18 15:56:21 -07:00

50 lines
1.7 KiB
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {AbsoluteFsPath} from '../../../../src/ngtsc/file_system';
import {JsonObject} from '../../packages/entry_point';
import {PackageJsonChange} from '../../writing/package_json_updater';
import {Task, TaskProcessingOutcome} from '../tasks/api';
/** A message reporting that an unrecoverable error occurred. */
export interface ErrorMessage extends JsonObject {
type: 'error';
error: string;
}
/** A message requesting the processing of a task. */
export interface ProcessTaskMessage extends JsonObject {
type: 'process-task';
task: Task;
}
/**
* A message reporting the result of processing the currently assigned task.
*
* NOTE: To avoid the communication overhead, the task is not included in the message. Instead, the
* master is responsible for keeping a mapping of workers to their currently assigned tasks.
*/
export interface TaskCompletedMessage extends JsonObject {
type: 'task-completed';
outcome: TaskProcessingOutcome;
message: string|null;
}
/** A message requesting the update of a `package.json` file. */
export interface UpdatePackageJsonMessage extends JsonObject {
type: 'update-package-json';
packageJsonPath: AbsoluteFsPath;
changes: PackageJsonChange[];
}
/** The type of messages sent from cluster workers to the cluster master. */
export type MessageFromWorker = ErrorMessage | TaskCompletedMessage | UpdatePackageJsonMessage;
/** The type of messages sent from the cluster master to cluster workers. */
export type MessageToWorker = ProcessTaskMessage;