You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| ✏️ | Specification primer |[google doc](https://docs.google.com/document/d/11rD3Azj63G2Si0VpokSpr-1ib3mFRFHSwN6tJb-0LQM/edit#heading=h.paewfy83tetm) continued in [wiki](https://github.com/serverlessworkflow/specification/wiki)|
Copy file name to clipboardExpand all lines: schema/workflow.json
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1447,14 +1447,14 @@
1447
1447
"type": "string",
1448
1448
"description": "Name of the iteration parameter that can be referenced in actions/workflow. For each parallel iteration, this param should contain an unique element of the inputCollection array"
1449
1449
},
1450
-
"max": {
1450
+
"batchSize": {
1451
1451
"type": [
1452
1452
"number",
1453
1453
"string"
1454
1454
],
1455
1455
"minimum": 0,
1456
1456
"minLength": 0,
1457
-
"description": "Specifies how upper bound on how many iterations may run in parallel"
1457
+
"description": "Specifies how many iterations may run in parallel at the same time. Used if 'mode' property is set to 'parallel' (default)"
1458
1458
},
1459
1459
"actions": {
1460
1460
"type": "array",
@@ -1505,6 +1505,15 @@
1505
1505
"default": false,
1506
1506
"description": "If true, this state is used to compensate another state. Default is false"
1507
1507
},
1508
+
"mode": {
1509
+
"type": "string",
1510
+
"enum": [
1511
+
"sequential",
1512
+
"parallel"
1513
+
],
1514
+
"description": "Specifies how iterations are to be performed (sequentially or in parallel)",
Copy file name to clipboardExpand all lines: specification.md
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2788,7 +2788,8 @@ The `timeouts` property can be used to define state specific timeout settings. I
2788
2788
| inputCollection | Workflow expression selecting an array element of the states data | string | yes |
2789
2789
| outputCollection | Workflow expression specifying an array element of the states data to add the results of each iteration | string | no |
2790
2790
| iterationParam | Name of the iteration parameter that can be referenced in actions/workflow. For each parallel iteration, this param should contain an unique element of the inputCollection array | string | yes |
2791
-
| max | Specifies how upper bound on how many iterations may run in parallel | string or number | no |
2791
+
| batchSize | Specifies how many iterations may run in parallel at the same time. Used if `mode` property is set to `parallel` (default). If not specified, its value should be the size of the `inputCollection` | string or number | no |
2792
+
| mode | Specifies how iterations are to be performed (sequentially or in parallel). Default is `parallel` | string | no |
2792
2793
| [actions](#Action-Definition) | Actions to be executed for each of the elements of inputCollection | array | yes |
2793
2794
| [timeouts](#Workflow-Timeouts) | State specific timeout settings | object | no |
2794
2795
| [stateDataFilter](#State-data-filters) | State data filter definition | object | no |
@@ -2854,10 +2855,18 @@ actions:
2854
2855
2855
2856
ForEach states can be used to execute [actions](#Action-Definition) for each element of a data set.
2856
2857
2857
-
Each iteration of the ForEach state should be executed in parallel.
2858
+
Each iteration of the ForEach state is by default executed in parallel by default.
2859
+
However, executing iterations sequentially is also possible by setting the value of the `mode` property to
2860
+
`sequential`.
2858
2861
2859
-
You can use the `max` property to set the upper bound on how many iterations may run in parallel. The default
2860
-
of the `max` property is zero, which places no limit on number of parallel executions.
2862
+
The `mode` property defines if iterations should be done sequentially or in parallel. By default
2863
+
(if `mode` is not specified) iterations should be done in parallel.
2864
+
2865
+
If the default `parallel` iteration mode is used, the `batchSize` property to the number of iterations (batch)
2866
+
that can be executed at a time. To give an example, if the number of iterations is 55 and `batchSize`
2867
+
is set to `10`, 10 iterations are to be executed at a time, meaning that the state would execute 10 iterations in parallel,
2868
+
then execute the next batch of 10 iterations. After 5 such executions, the remaining 5 iterations are to be executed in the last batch.
2869
+
The batch size value must be greater than 1. If not specified, its value should be the size of the `inputCollection` (all iterations).
2861
2870
2862
2871
The `inputCollection` property is a workflow expression which selects an array in the states data. All iterations
2863
2872
are performed against data elements of this array. If this array does not exist, the runtime should throw
0 commit comments