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
| ✔️| Update ForEach state - adding sequential exec option and batch size for parallel option |[spec doc](../specification.md)|
47
47
| ✔️| Update to error handling and retries. Retries are now per action rather than per state. Added option of automatic retries for actions |[spec doc](../specification.md)|
48
+
| ✔️| Added "continueAs" property to end definitions |[spec doc](https://github.com/serverlessworkflow/specification/blob/0.6.x/specification.md)|
Copy file name to clipboardExpand all lines: schema/workflow.json
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -250,6 +250,43 @@
250
250
}
251
251
]
252
252
},
253
+
"continueasdef": {
254
+
"oneOf": [
255
+
{
256
+
"type": "string",
257
+
"description": "Unique id of the workflow to be continue execution as. Entire state data is passed as data input to next execution",
258
+
"minLength": 1
259
+
},
260
+
{
261
+
"type": "object",
262
+
"properties": {
263
+
"workflowId": {
264
+
"type": "string",
265
+
"description": "Unique id of the workflow to continue execution as"
266
+
},
267
+
"version": {
268
+
"type": "string",
269
+
"description": "Version of the workflow to continue execution as",
270
+
"minLength": 1
271
+
},
272
+
"data": {
273
+
"type": [
274
+
"string",
275
+
"object"
276
+
],
277
+
"description": "If string type, an expression which selects parts of the states data output to become the workflow data input of continued execution. If object type, a custom object to become the workflow data input of the continued execution"
+[Compensation and Active States](#compensation-and-active-states)
88
88
+[Unrecoverable errors during compensation](#unrecoverable-errors-during-compensation)
89
+
*[Continuing as a new Execution](#continuing-as-a-new-execution)
90
+
+[ContinueAs in sub workflows](#continueas-in-sub-workflows)
89
91
*[Workflow Versioning](#workflow-versioning)
90
92
*[Workflow Constants](#workflow-constants)
91
93
*[Workflow Secrets](#workflow-secrets)
@@ -4618,8 +4620,8 @@ Can be either `boolean` or `object` type. If type boolean, must be set to `true`
4618
4620
"end": true
4619
4621
```
4620
4622
4621
-
In this case it's assumed that the `terminate` property has its default value of `false`, and the `produceEvents` and
4622
-
`compensate`properties are not defined.
4623
+
In this case it's assumed that the `terminate` property has its default value of `false`, and the `produceEvents`,
4624
+
`compensate`, and `continueAs` properties are not defined.
4623
4625
4624
4626
If the end definition is of type `object`, it has the following structure:
4625
4627
@@ -4628,6 +4630,7 @@ If the end definition is of type `object`, it has the following structure:
4628
4630
| terminate | If true, terminates workflow instance execution | boolean | no |
4629
4631
| produceEvents | Array of [producedEvent](#ProducedEvent-Definition) definitions. Defines events that should be produced. | array | no |
4630
4632
| [compensate](#Workflow-Compensation) | If set to `true`, triggers workflow compensation before workflow execution completes. Default is `false` | boolean | no |
4633
+
| [continueAs](#continuing-as-a-new-execution) | Defines that current workflow execution should stop, and execution should continue as a new workflow instance of the provided id | string or object | no |
4631
4634
4632
4635
<details><summary><strong>Click to view example definition</strong></summary>
4633
4636
<p>
@@ -4669,8 +4672,8 @@ produceEvents:
4669
4672
4670
4673
End definitions are used to explicitly define execution completion of a workflow instance or workflow execution path.
4671
4674
A workflow definition must include at least one [workflow state](#Workflow-States).
4672
-
Note that [Switch states](#Switch-State) cannot declare to be workflow end states. Switch states must end
4673
-
their execution followed by a transition another workflow state, given their conditional evaluation.
4675
+
Note that [Switch states](#Switch-State) cannot declare to be workflow end states. Their conditions however can
4676
+
define a stop of workflow execution.
4674
4677
4675
4678
The `terminate` property, if set to `true`, completes the workflow instance execution, this any other active
4676
4679
execution paths.
@@ -4685,6 +4688,15 @@ is if workflow execution reaches a state that defines an end definition with `te
4685
4688
or, if the [`workflowExecTimeout`](#Workflow-Timeouts) property is defined, the time defined in its `interval`
4686
4689
is reached.
4687
4690
4691
+
The [compensate](#Workflow-Compensation) property defines that workflow compensation should be performed before the workflow
4692
+
execution is completed.
4693
+
4694
+
The [continueAs](#Continuing as a new Execution) property defines that the current workflow instance should stop its execution,
4695
+
and worklow execution should continue as a new instance of a new workflow.
4696
+
When defined, it should be assumed that `terminate` is `true`. If `continueAs` is defined, and `terminate` is explicitly
4697
+
set to false, runtimes should report this to users. Producing events, and compensation should still be performed (if defined)
4698
+
before the workflow execution is stopped, and continued as a new workflow instance with the defined workflow id.
4699
+
4688
4700
##### ProducedEvent Definition
4689
4701
4690
4702
| Parameter | Description | Type | Required |
@@ -5746,6 +5758,66 @@ States that are marked as `usedForCompensation` can define [error handling](#Wor
5746
5758
(errors not explicitly handled),
5747
5759
workflow execution should be stopped, which is the same behavior as when not using compensation as well.
5748
5760
5761
+
### Continuing as a new Execution
5762
+
5763
+
In some cases our workflows are deployed and executed on runtimes and/or cloud platforms that expose some
5764
+
execution limitations such as finite execution duration, finite number of workflow transitions, etc.
5765
+
Some runtimes, especially when dealing with stateful workflow orchestrations have a finite limit of
5766
+
execution history log sizes, meaning that once a long-running workflow reaches these limits workflow executions is
5767
+
likely to be forced to stop before reaching its completion. This can result in unexpected issues, especially with
5768
+
mission-critical workflows.
5769
+
5770
+
For those cases, the Serverless Workflow DSL provides a way to explicitly define stopping the current workflow
5771
+
instance execution, and starting a new one (for the same workflow id or a different one).
5772
+
This can be done via the [end definitions](#end-definition) `continueAs` property.
5773
+
5774
+
The end definitions `continueAs` can be either of type `string` or `object`.
5775
+
If string type, it contains the unique workflow id of the workflow that the execution should continue as, for example:
5776
+
5777
+
5778
+
```json
5779
+
{
5780
+
"end": {
5781
+
"continueAs": "myworkflowid"
5782
+
}
5783
+
}
5784
+
```
5785
+
5786
+
Defining this should stop the current workflow execution, and continue execution as a new workflow instance of the
5787
+
workflow which defines the workflow id of "myworkflowid". The state data where this is define should
5788
+
become the workflow data input of the workflow that is continuing the current workflow execution.
5789
+
5790
+
Note that any defined `produceEvents` and `compensate` definitions should be honored before `continueAs` is applied.
5791
+
5792
+
If `object` type, the `continueAs` property has the following properties:
5793
+
5794
+
| Parameter | Description | Type | Required |
5795
+
| --- | --- | --- | --- |
5796
+
| workflowId | Unique id of the workflow to continue execution as. | string | yes |
5797
+
| version | Version of the workflow to continue execution as. | string | no |
5798
+
| data | If string type, a workflow expression which selects parts of the states data output to become the workflow data input of continued execution. If object type, a custom object to become the workflow data input of the continued execution. | string or object | no |
5799
+
| [`workflowExecTimeout`](#Workflow-Timeouts) | Workflow execution timeout to be used by the workflow continuing execution. Overwrites any specific settings set by that workflow. | string or object | no |
5800
+
5801
+
Continuing execution with `continueAs` can also be used inside sub-workflow executions, which brings its next use case.
5802
+
5803
+
#### ContinueAs in sub workflows
5804
+
5805
+
Workflows can invoke sub-workflows during their execution. In Serverless Workflow DSL, sub-workflows are invoked
5806
+
similarly to other function types via the [SubFlowRef Definition](#SubFlowRef-Definition)
5807
+
in workflow states [Action](#Action-Definition) definitions.
5808
+
5809
+
Just like "parent" workflows, sub-workflow can also be long-running, and can run into the same type of runtime/serverless platform
5810
+
limitations as previously discussed. As such they can also use `continueAs` to stop their current execution and continue it as
5811
+
a new one of the same or different workflow id.
5812
+
5813
+
Note that when a sub-workflow is invoked it can produce a result that is then merged into the parent workflow state data.
5814
+
This may bring up a question as to what happens when a sub-workflow calls `continueAs` in terms of what is returned as
5815
+
result to of its invocation by the parent workflow.
5816
+
5817
+
No matter how many times sub-workflow may use `continueAs`, to the parent workflow it should be as a single invocation is performed,
5818
+
meaning that the results of the last sub-workflow invocation (triggered by `continueAs`) should be used as the
5819
+
data returned by the invocation of the sub-workflow to the parent workflow.
5820
+
5749
5821
### Workflow Versioning
5750
5822
5751
5823
In any application, regardless of size or type, one thing is for sure: changes happen.
0 commit comments