Mixed Flow
Overview
Mixed flow
allows execution of other flows (child flows) within the flow (parent). The execution can be done in parallel (asynchronously) or sequentially (synchronously).
This is useful when there is common logic that is shared among multiple flows (e.g. jwt validation, re-mapping of doc
nodes) and allows to separate this logic into a child flow that then can be called from the parent.
Configuration
mode
- this option allows the user to specify how the flow configuration data should be passed to the step.flow (default)
- straightforward ui to fill the necessary inputs:list of flows to execute
- one or more flows that can be selected for execution (note: in case of synchronous execution the order of the flows is important)flow name
- the name of the flow to execute;payload path (defaults to doc)
- path to the payload of data to send to the flow;target path
- where to store the result of the executed flow;Store target path results in cache
- if checked will enable caching response valuesCache Key
- if specified, will be used as key to store the cached responseCache clean-up condition
- If condition is true, then step cache is cleared and data is not cached, else if condition is false or not defined, then step behaves as usually.TTL
- time in minutes for how long to keep the cached resultsprocess data as array
- when checked, allows the user to pass data to the flow as an array of data objects.concurrency
- in case of async execution - this sets the maximum amount of flows to execute at a single time This will result in a loop of flow executions with these data objects being passed in each iteration;
bind
- this option changes how one would pass the configuration data to the step. The path of this input should result in an array of objects containing the following structure of previously described data:
Execute flows in parallel
- Default is false, which means flows will be executed in serial. If set to true, the all flows will be executed in parallel.Execute flows in background
- Default is false. If set to true, the mixed flow step will execute flows in background and won't wait till it's finished before returning response.
The flows executed in backgroud will not modify the doc
object of main/parent flow.
{
"flows": [
{
"flowId": "myFlow",
"payload": "data.toSend",
"targetPath": "result",
"processAsArray": false,
"cacheable": false,
"ttl": 0
}
]
}
Caching
Mixed flow step supports flow execution result caching. Result caching happens based on flow input data. Because of this it is advised to use payload path to specify only part of doc needed to execute flow.
Examples
Child flow
{
"id": "9ca676de-a772-4ac6-8220-71034eff61da",
"name": "exampleSubFlow",
"flow": {
"name": "exampleSubFlow",
"description": "",
"steps": [
{
"stepType": "code",
"color": "rgb(223,204,241)",
"displayName": "JS Code Functions",
"isSelected": true,
"config": {
"codeBlock": "number * 2",
"targetPath": "number"
},
"condition": "{{number}}"
}
]
},
"inputSchema": {},
"createDate": "2021-10-10T06:03:13.712Z",
"tags": [
"example"
],
"inputSchemaLabel": "",
"version": 1
}
Synchronous execution
Step configuration
{
"stepType": "mixedflow",
"color": "rgb(189,208,196)",
"displayName": "Mixed-flow",
"isSelected": true,
"config": {
"mode": "flow",
"async": false,
"flowIds": [
{
"flowId": "exampleSubFlow"
},
{
"flowId": "exampleSubFlow"
}
],
"concurrency": 0
}
}
Result
{
"doc": {
"number": 64
},
"errors": [],
"performance": {
"steps": [
{
"step": "mixedflow",
"executionTime": 57
}
],
"executionTimeOfFlow": 57,
"timeMetric": "ms"
}
}
Flow
{
"flow": {
"name": "exampleMixedFlow",
"description": "",
"steps": [
{
"stepType": "mixedflow",
"color": "rgb(189,208,196)",
"displayName": "Mixed-flow",
"isSelected": true,
"config": {
"mode": "flow",
"async": false,
"flowIds": [
{
"flowId": "exampleSubFlow"
},
{
"flowId": "exampleSubFlow"
}
],
"concurrency": 0
}
}
]
},
"name": "exampleMixedFlow",
"inputSchema": {
"number": 16
},
"tags": [
"example"
],
"inputSchemaLabel": "",
"version": 1,
"id": "4f770ce8-d360-4aaa-a495-d8685b33b5ba",
"createDate": "2021-10-10T06:06:16.155Z"
}
Asynchronous execution
The only difference between these two flows is that we have changed the execution mode to async
and set the limit of parallel flows to execute to 2.
Step configuration
{
"stepType": "mixedflow",
"color": "rgb(189,208,196)",
"displayName": "Mixed-flow",
"isSelected": true,
"config": {
"mode": "flow",
"async": true,
"flowIds": [
{
"flowId": "exampleSubFlow"
},
{
"flowId": "exampleSubFlow"
}
],
"concurrency": 2
}
}
Result
Since the flows are executed in parallel, both receive the starting input - so the result is that the input number gets multiplied by 2 instead of 16 * 2 * 2
because in essence both flows receive the same input number: 16
and then at the end of run both flows set the number to 32.
{
"doc": {
"loopResult": 32
},
"errors": [],
"performance": {
"steps": [
{
"step": "mixedflow",
"executionTime": 52
}
],
"executionTimeOfFlow": 52,
"timeMetric": "ms"
}
}
Flow
{
"flow": {
"name": "exampleMixedFlow",
"description": "",
"steps": [
{
"stepType": "mixedflow",
"color": "rgb(189,208,196)",
"displayName": "Mixed-flow",
"isSelected": true,
"config": {
"mode": "flow",
"async": true,
"flowIds": [
{
"flowId": "exampleSubFlow"
},
{
"flowId": "exampleSubFlow"
}
],
"concurrency": 2
}
}
]
},
"name": "exampleMixedFlow",
"inputSchema": {
"loopResult": 16
},
"tags": [
"example"
],
"inputSchemaLabel": "",
"version": 1,
"id": "4f770ce8-d360-4aaa-a495-d8685b33b5ba",
"createDate": "2021-10-10T06:06:16.155Z"
}