@rushstack/operation-graph
Version:
Library for managing and executing operations in a directed acyclic graph.
46 lines • 2.21 kB
TypeScript
import type { ITerminal } from '@rushstack/terminal';
import type { Operation, OperationRequestRunCallback } from './Operation';
import type { OperationGroupRecord } from './OperationGroupRecord';
import { OperationStatus } from './OperationStatus';
/**
* Options for the current run.
*
* @beta
*/
export interface IOperationExecutionOptions<TOperationMetadata extends {} = {}, TGroupMetadata extends {} = {}> {
abortSignal: AbortSignal;
parallelism: number;
terminal: ITerminal;
requestRun?: OperationRequestRunCallback;
beforeExecuteOperation?: (operation: Operation<TOperationMetadata, TGroupMetadata>) => void;
afterExecuteOperation?: (operation: Operation<TOperationMetadata, TGroupMetadata>) => void;
beforeExecuteOperationGroup?: (operationGroup: OperationGroupRecord<TGroupMetadata>) => void;
afterExecuteOperationGroup?: (operationGroup: OperationGroupRecord<TGroupMetadata>) => void;
}
/**
* A class which manages the execution of a set of tasks with interdependencies.
* Initially, and at the end of each task execution, all unblocked tasks
* are added to a ready queue which is then executed. This is done continually until all
* tasks are complete, or prematurely fails if any of the tasks fail.
*
* @beta
*/
export declare class OperationExecutionManager<TOperationMetadata extends {} = {}, TGroupMetadata extends {} = {}> {
/**
* The set of operations that will be executed
*/
private readonly _operations;
/**
* The total number of non-silent operations in the graph.
* Silent operations are generally used to simplify the construction of the graph.
*/
private readonly _trackedOperationCount;
private readonly _groupRecords;
constructor(operations: ReadonlySet<Operation<TOperationMetadata, TGroupMetadata>>);
/**
* Executes all operations which have been registered, returning a promise which is resolved when all the
* operations are completed successfully, or rejects when any operation fails.
*/
executeAsync(executionOptions: IOperationExecutionOptions<TOperationMetadata, TGroupMetadata>): Promise<OperationStatus>;
}
//# sourceMappingURL=OperationExecutionManager.d.ts.map