Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 1x 38x 38x 38x 38x 38x 76x 6x 6x 6x 6x | import Node, {execute as nodeExecute} from "./Node";
import {Graph, SchedulerEvent, newId, EdgeError, Connector} from "./Shared";
import Scheduler from "./Scheduler";
/** The edge of a node, what connectors connect to. */
export default interface Edge {
/** Name of the edge */
field: string;
/** Connectors that connect the edges together */
connectors: Connector[];
}
/** Executes a given edge. Edges are always inputs (LTR) */
export async function execute(scheduler: Scheduler, graph: Graph, node: Node, field: string, value: any): Promise<any> {
const start = Date.now();
scheduler.dispatchEvent("beginedge", {
time: start,
id: newId(),
nodeId: node.id,
graphId: graph.id,
field,
value,
} as SchedulerEvent);
scheduler.logger.debug("Edge: Node.execute: node.id:field " + node.id + ":" + field);
function end(): void {
const now = Date.now();
scheduler.dispatchEvent("endedge", {
time: now,
id: newId(),
duration: now - start,
nodeId: node.id,
graphId: graph.id,
field,
value,
} as SchedulerEvent);
}
await nodeExecute(scheduler, graph, node, field, value)
.then(end)
.catch((err) => {
const er = new Error("Edge: Error occured during node.execute: " + err.stack);
scheduler.logger.error(er.stack);
scheduler.dispatchEvent("error", {
id: newId(),
time: Date.now(),
err: er,
message: er.toString(),
nodeId: node.id,
graphId: graph.id,
field,
value,
} as EdgeError);
end();
});
}
|