Graph to execute.
What will appear as the this
object for any node set function that executes on your graph.
Object that will be available to node set functions during graph execution. You can alter this object before or after instantiating the scheduler. See NodeInterface.
Optional logging function to listen to info and debug messages coming out of the scheduler. Functional messages are emitted via the event emitter.
To start graph execution, instantiate the scheduler and pass your graph to it.
const scheduler = new Scheduler(myGraphJSON);
scheduler.url("my-graph-url");
You can also execute the graph and pass context variables to the nodes.
In the example below, nodes executing on myGraph will have access to {foo: "bar"}
by accessing this.foo
at runtime.
This allows you to attach properties like server response functions, database connections, client side component references, and many other things
use full to the node's set function on runtime.
const scheduler = new Scheduler(myGraphJSON, {foo: "bar"});
Nodes now have a mutable object with which they can share long running objects, data caches or other resources that are expensive to instantiate per edge invocation. State is whatever you pass into before you instantiate the scheduler or at run time. The scheduler has no opinion.
const scheduler = new Scheduler(myGraphJSON, {}, {foo: bar});
You can listen to info and debug messages emitted from the scheduler by attaching an object or class that matches the Logger interface. Which happens to be almost exactly like console.
```TypeScript const scheduler = new Scheduler(myGraphJSON, {}, {}, console);
Occurs after a node's set function has completed. Contains the return value of the function. Although this return value is present, using it is considered an anti-pattern and is only included for debugging.
Occurs when the graph begins to navigate to a node's URL via the url function.
Occurs as a node's set function has called edges[field] = <value>;
.
Occurs when a connector value enters into a node's edge (input).
Occurs at the end of the initial graph promise chain. The graph may continue to run as asynchronous functions return.
Occurs when a connector promise chain has completed after a node's set function has called edges[field] = <value>;
.
Occurs after all all edge promises are completed. Note: If your nodes do not return promises.
Occurs just before set is called. You can use setContext
to alter the this
context object of the node just before the node's set function is invoked.
The domain specific context object. User defined and used by set methods.
Holds events in the event bus
The base graph
Loader for loading graphs
The parameterized path to linked graph documents
Logging functions
Node specific runtime cache object. Used in set functions for any reason the author sees fit.
Loader for loading nodes
The parameterized path to linked node documents
Edge traversal counter
Mutable state object. This object can be changed and examined later.
Adds an event listener
Dispatches an event
Invoke a Node's Edge (set function).
const scheduler = new Scheduler(myGraphJSON);
scheduler.url("my-graph-url");
Invoke a Node's Edge (set function), and send a value to the edge.
const scheduler = new Scheduler(myGraphJSON);
scheduler.url("my-graph-url", "some value");
Invoke a Node's Edge (set function), and send a value to the edge.
const scheduler = new Scheduler(myGraphJSON);
scheduler.url("my-graph-url", "some value", "some_field");
By passing a node instance, you can invoke nodes embedded in inner graphs.
```TypeScript const scheduler = new Scheduler(myGraphJSON); scheduler.url("my-graph-url", "some value", "some_field", myInnerNodeInstance);
Generated using TypeDoc
Scheduler
This is the graph execution engine. To create graphs, see Plastic-IO Graph Editor.
The Plastic-IO Graph Editor uses this engine to test and execute graphs in the browser.
If you're trying to execute graphs in an AWS environment, you might want to check out the Plastic-IO Graph Server.
If you want to implement the scheduler yourself and run graphs in your own way, then you have come to the right place!
To begin the execution of a graph, you must first instantiate your graph in the Scheduler. See the constructor for more information on instantiation. After you instantiate the scheduler, you can call url to directly invoke a node's edge (set function).
Graph
Graphs contain arrays of Nodes. Nodes are executable units of code and can be local to the graph, or reference other nodes or graphs.
Scheduler Execution Digram
edges[field]
which invokes n connectors referencing other node edges