-
Notifications
You must be signed in to change notification settings - Fork 1
Design: Call Node
There are many situations where executing other flow/node in place of a node in a flow is useful similar to procedure call in other programming language.
The top-left flow and the top-right flow has similar structure - read message, apply some process, then output message. If we can replace a node execution with other node or flow, we can create reusable flow pattern (template flow). In this case, the middle flow represents a reusable flow pattern of two flows on the top. If we can replace execution of Call#1 with In#1A and Call#2 with Out#2A, we can obtain similar flow as top-left one. Similarly, if we can replace execution of *Call#*1 with In#1B and Call#2 with Out#2B, we can obtain similar flow as top-right one. Call Node proposed by this document can support creation of such kind of reusable flows.
This document describes two proposal on this: call node and link-call node.
-
A node specified by a Call node setting panel is invoked in place of the Call node as if the node is placed at the Call node location.
-
Number of output port of a call node and its target node must be the same. Otherwise, error is reported.
-
Call node specifies single target node in its settings panel. If calling a flow fragment is needed, the flow must be converted to a Subflow. Nested call can be implemented placing a call node indide a target subflow node.
-
Call node has two modes: Direct and Indirect
-
Direct mode
- Target node is specified directly by call node’s setting
-
Indirect mode
- Specify conditions to select target node from settings panel of Call node. Candidate conditions: direct specification of nodes, topic name matching, belonging tabs, etc.
- In direct node, node selection operation by users are not needed. Node-RED runtime calculates target nodes of a call node after deply of a flow (or some user operation).
- Number of target node that is selected at runtime is limited to one.
-
Direct mode
-
Link-call node calls link-in node and returns output message of link-out node from corresponding output port of link-call node.
-
Link-call node specifies relationship between input a node to link-in, outputs to link-outs toin settings panel.
-
Any number of nodes can be contained between link-in and link-out nodes.
-
Link-call node can be arbitrary nested.
-
In order to process flow of control and flow of messages appropriately, some meta-data must be retained in the flow between link-in and link-out. This means the meta-data must be retained when a message is passed through called flow fragment.
Pros | Cons | |
---|---|---|
Call Node | - can prohibit creation of illegal flow - meta-data in a message is not needed |
- target node is restricted to single node - nested call needs creation of subflow - needs flow of control concept |
Link-Call Node | - can call arbitrary flow fragments - similar to link node concept |
- unmatched link-in/out creates illegal flow - meta-data should be maintained in messages passed in called flow |
Call node or Call-Link node introduced a flow of control that is not explicitly represented as nodes connection. This makes understanding flow difficult. To cope with this, introduction of new form of nodes link seems to be useful.
We introduce Control Link that represents special kind of implicit control flow such as introduced by Call/Call-Link node. It connects from bottom of Call/Call-Link node to top of target node. The port at bottom at top of nodes are called Control Port. This Control Link should be useful for representing implicit control flow introduced by Catch/Status/Complete node.
When Call/Call-Link node is placed inside SUBFLOW, the subflow can have control port that connects Call/Call-Link inside the subflow to target nodes.