@akala/core
Version:
52 lines (51 loc) • 1.67 kB
TypeScript
import { EventEmitter } from './events/event-emitter.js';
import type { IEvent } from './events/shared.js';
import { type Task } from './sequencify.js';
interface EventMap {
start: IEvent<[string[]], void>;
task_start: IEvent<[{
message: string;
task: Task;
taskName: string;
}], void>;
task_stop: IEvent<[{
message: string;
task: Task;
taskName: string;
}, Task], void>;
error: IEvent<[{
error: Error;
task: Task;
}], void>;
stop: IEvent<[Error] | [], void>;
}
/**
* Orchestrates task execution with dependency management
* @class Orchestrator
* @extends EventEmitter
* @fires Orchestrator#start
* @fires Orchestrator#task_start
* @fires Orchestrator#task_stop
* @fires Orchestrator#error
* @fires Orchestrator#stop
*/
export declare class Orchestrator extends EventEmitter<EventMap> {
readonly tasks: Record<string, Task & {
name: string;
action?: () => void | Promise<void>;
}>;
/**
* Adds a task to the orchestrator
* @param {string} name - Unique identifier for the task
* @param {string[]} dependencies - Array of task names this task depends on
* @param {function} [action] - Optional async function to execute for the task
*/
add(name: string, dependencies: string[], action?: () => void | Promise<void>): void;
/**
* Executes tasks in dependency order
* @param {...string} names - Task names to execute (and their dependencies)
* @returns {Promise<void>} Resolves when all tasks complete, rejects on critical error
*/
start(...names: string[]): Promise<void>;
}
export {};