UNPKG

topology-runner

Version:

Run a topology consisting of a directed acyclic graph

52 lines (50 loc) 2 kB
import { DAG, Snapshot, Options, SnapshotData, ResumeTopology, RunTopology, Spec } from './types'; import makeError from 'make-error'; export declare const TopologyError: makeError.Constructor<makeError.BaseError>; /** * Handle excludeNodes and includeNodes options, transforming the * DAG accordingly. Only one option will be handled, not both. */ export declare const filterDAG: (dag: DAG, options?: Options) => DAG; /** * Get a list of nodes where all dependencies have completed and the * node's status is pending. */ export declare const getNodesReadyToRun: (dag: DAG, data: SnapshotData) => string[]; /** * Get the input data from dependencies. */ export declare const getInputData: (dag: DAG, node: string, data: SnapshotData) => any[]; /** * Check if all nodes in the DAG are in the spec */ export declare const getMissingSpecNodes: (spec: Spec, dag: DAG) => string[]; /** * Set input for nodes with no dependencies to data, if exists. */ export declare const initSnapshotData: (dag: DAG, data?: any) => SnapshotData; /** * Run a topology consisting of a DAG and functions for each node in the * DAG. A subset of the DAG can be executed by setting either includeNodes * or excludeNodes. Initial data is passed via options.data. Optionally * pass a context blob to all nodes. * * Returns an event emitter and a promise. The event emitter emits data * every time the topology snapshot updates. Events include: data, error, and * done. */ export declare const runTopology: RunTopology; /** * Transform a previously run snapshot into one that is ready to * be run again. */ export declare const getResumeSnapshot: (snapshot: Snapshot) => Snapshot; /** * Resume a topology from a previous snapshot. Optionally pass a context * blob to all nodes. * * Returns an event emitter and a promise. The event emitter emits data * every time the topology snapshot updates. Events include: data, error, and * done. */ export declare const resumeTopology: ResumeTopology;