@@ -1897,11 +1897,11 @@ For more information, see the [workflow error handling and retrying section](#wo
1897
1897
| id | Unique state id | string | no |
1898
1898
| name |State name | string | yes |
1899
1899
| type |State type | string | yes |
1900
- | waitForCompletion |If workflow execution must wait for sub-workflow to finish before continuing | boolean | yes |
1900
+ | waitForCompletion | If workflow execution must wait for sub-workflow to finish before continuing | boolean | yes |
1901
1901
| workflowId |Sub-workflow unique id | boolean | no |
1902
1902
| [stateDataFilter](#state-data-filter) | State data filter | object | no |
1903
1903
| [onError](#Workflow-Error-Handling) | States error handling definitions | array | no |
1904
- | [transition](#Transitions) |Next transition of the workflow after subflow has completed | object | yes (if end is not defined) |
1904
+ | [transition](#Transitions) | Next transition of the workflow after subflow has completed | object | yes (if end is not defined) |
1905
1905
| dataInputSchema | URI to JSON Schema that state data input adheres to | string | no |
1906
1906
| dataOutputSchema | URI to JSON Schema that state data output adheres to | string | no |
1907
1907
| [metadata](#Workflow-Metadata) | Metadata information| object | no |
@@ -1947,27 +1947,28 @@ end:
1947
1947
1948
1948
</details>
1949
1949
1950
- It is often the case that you want to group your workflows into small, reusable logical units that perform certain needed functionality.
1951
- Even though you can use the Event or Callback states to call externally deployed services (via function), at times
1952
- there is a need to include/inject another serverless workflow (from classpath/local file system etc, depending on the implementation logic).
1953
- In that case you would use the SubFlow state.
1954
- It also allows developers to model their workflows with reusability and logical grouping in mind.
1950
+ Often you want to group your workflows into small logical units that solve a particular business problem and can be reused in
1951
+ multiple other workflow definitions.
1955
1952
1956
- This state allows developers to include/inject a uniquely identified sub-workflow and start its execution.
1957
- Another use of this state is within [branches](#parallel-state-branch) of the [Parallel State](#Parallel-State).
1958
- Instead of having to define all states
1959
- in each branch, you could separate the branch states into individual sub-workflows and call the SubFlow state
1960
- as a single state in each.
1953
+ <p align="center">
1954
+ <img src="media/spec/subflowstateref.png" height="350px" alt="Referencing reusable workflow via SubFlow states"/>
1955
+ </p>
1956
+
1957
+ Reusable workflow are referenced by their `id` property via the SubFlow states`workflowId` parameter.
1958
+
1959
+ Each referenced workflow receives the SubFlow states data as workflow data input.
1960
+
1961
+ The `waitForCompletion` property defines if the SubFlow state should wait until the referenced reusable workflow
1962
+ has completed its execution.
1961
1963
1962
- Sub-workflows must have a defined start and end states.
1963
- The `waitForCompletion` property defines if the SubFlow state should wait until execution of the sub-workflow
1964
- is completed or not.
1964
+ If `waitForCompletion` is "true", SubFlow state execution must wait until the referenced workflow has completed its execution.
1965
+ In this case the workflow data output of the referenced workflow can and should be merged with the SubFlow states state data.
1965
1966
1966
- Each sub-workflow receives the same copy of the SubFlow state's data input.
1967
- If the `waitForCompletion` property is set to true, sub-workflows have the ability to edit the parent's workflow data.
1968
- If the `waitForCompletion` property is set to false, data access to the parent workflow should not be allowed .
1967
+ If `waitForCompletion` is set to "false" the parent workflow can continue its execution while the referenced workflow
1968
+ is being executed. For this case, the referenced (child) workflow data output cannot be merged with the SubFlow states
1969
+ state data (as by the time its completion the parent workflow execution has already continued) .
1969
1970
1970
- Sub- workflows inherit all the [function](#Function-Definition) and [event](#Event-Definition) definitions of their parent workflow .
1971
+ Referenced workflows must declare their own [function](#Function-Definition) and [event](#Event-Definition) definitions.
1971
1972
1972
1973
# ### Inject State
1973
1974
0 commit comments