Skip to content

Commit 3b6f976

Browse files
Merge pull request #819 from fjtirado/Fix_#816
Fix #816 - Allows using expression for timeout duration
2 parents 0dfdf42 + 3aeec44 commit 3b6f976

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

schema/retries.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
},
3838
"delay": {
3939
"type": "string",
40-
"description": "Time delay between retry attempts (ISO 8601 duration format)"
40+
"description": "Time delay between retry attempts (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)"
4141
},
4242
"maxDelay": {
4343
"type": "string",
44-
"description": "Maximum time delay between retry attempts (ISO 8601 duration format)"
44+
"description": "Maximum time delay between retry attempts (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)"
4545
},
4646
"increment": {
4747
"type": "string",
48-
"description": "Static value by which the delay increases during each attempt (ISO 8601 time format)"
48+
"description": "Time delay increment during each attempt (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)"
4949
},
5050
"multiplier": {
5151
"type": [
@@ -73,7 +73,7 @@
7373
],
7474
"minimum": 0,
7575
"maximum": 1,
76-
"description": "If float type, maximum amount of random time added or subtracted from the delay between each retry relative to total delay (between 0 and 1). If string type, absolute maximum amount of random time added or subtracted from the delay between each retry (ISO 8601 duration format)"
76+
"description": "If float type, maximum amount of random time added or subtracted from the delay between each retry relative to total delay (between 0 and 1). If string type, absolute maximum amount of random time added or subtracted from the delay between each retry (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)"
7777
}
7878
},
7979
"additionalProperties": false,

schema/timeouts.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
"oneOf": [
4444
{
4545
"type": "string",
46-
"description": "Workflow execution timeout duration (ISO 8601 duration format). If not specified should be 'unlimited'",
46+
"description": "Workflow execution timeout duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration). If not specified should be 'unlimited'",
4747
"minLength": 1
4848
},
4949
{
5050
"type": "object",
5151
"properties": {
5252
"duration": {
5353
"type": "string",
54-
"description": "Workflow execution timeout duration (ISO 8601 duration format). If not specified should be 'unlimited'",
54+
"description": "Workflow execution timeout duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration). If not specified should be 'unlimited'",
5555
"minLength": 1
5656
},
5757
"interrupt": {
@@ -74,22 +74,22 @@
7474
},
7575
"stateExecTimeout": {
7676
"type": "string",
77-
"description": "Workflow state execution timeout duration (ISO 8601 duration format)",
77+
"description": "Workflow state execution timeout duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)",
7878
"minLength": 1
7979
},
8080
"actionExecTimeout": {
8181
"type": "string",
82-
"description": "Action execution timeout duration (ISO 8601 duration format)",
82+
"description": "Action execution timeout duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)",
8383
"minLength": 1
8484
},
8585
"branchExecTimeout": {
8686
"type": "string",
87-
"description": "Branch execution timeout duration (ISO 8601 duration format)",
87+
"description": "Branch execution timeout duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)",
8888
"minLength": 1
8989
},
9090
"eventTimeout": {
9191
"type": "string",
92-
"description": "Timeout duration to wait for consuming defined events (ISO 8601 duration format)",
92+
"description": "Timeout duration to wait for consuming defined events (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration)",
9393
"minLength": 1
9494
}
9595
}

schema/workflow.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@
174174
"properties": {
175175
"before": {
176176
"type": "string",
177-
"description": "Amount of time (ISO 8601 duration format) to sleep before function/subflow invocation. Does not apply if 'eventRef' is defined."
177+
"description": "Amount of time (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep before function/subflow invocation. Does not apply if 'eventRef' is defined."
178178
},
179179
"after": {
180180
"type": "string",
181-
"description": "Amount of time (ISO 8601 duration format) to sleep after function/subflow invocation. Does not apply if 'eventRef' is defined."
181+
"description": "Amount of time (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep after function/subflow invocation. Does not apply if 'eventRef' is defined."
182182
}
183183
},
184184
"anyOf": [
@@ -663,7 +663,7 @@
663663
},
664664
"duration": {
665665
"type": "string",
666-
"description": "Duration (ISO 8601 duration format) to sleep"
666+
"description": "Duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep"
667667
},
668668
"transition": {
669669
"description": "Next transition of the workflow after the workflow sleep",

specification.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,7 +2623,7 @@ The `timeouts` property can be used to define state specific timeout settings. S
26232623
| --- | --- | --- | --- |
26242624
| name | Unique State name. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
26252625
| type | State type | string | yes |
2626-
| duration | Duration (ISO 8601 duration format) to sleep. For example: "PT15M" (sleep 15 minutes), or "P2DT3H4M" (sleep 2 days, 3 hours and 4 minutes) | string | yes |
2626+
| duration | Duration (ISO 8601 literal duration or an expression which evaluation results in an ISO 8601 duration) to sleep. For example: "PT15M" (sleep 15 minutes), or "P2DT3H4M" (sleep 2 days, 3 hours and 4 minutes), or $CONST.timeout, where timeout value is "PT15M" | string | yes |
26272627
| [transition](#Transitions) | Next transition of the workflow after the sleep | string or object | yes (if `end` is not defined) |
26282628
| [end](#End-Definition) | Is this state an end state | boolean or object | yes (if `transition` is not defined) |
26292629

@@ -2665,7 +2665,7 @@ transition: get-job-status
26652665

26662666
Sleep state
26672667
suspends workflow execution for a given time duration. The delay is defined in its `duration` property using the ISO 8601
2668-
duration format.
2668+
duration format. Note that ISO 8601 can be the result of evaluating an expression.
26692669

26702670
Note that `transition` and `end` properties are mutually exclusive, meaning that you cannot define both of them at the same time.
26712671
##### Parallel State
@@ -4002,8 +4002,8 @@ referenced `produced` event via its `produceEventRef` property and a `consumed`
40024002

40034003
The `sleep` property can be used to define time periods that workflow execution should sleep
40044004
before and/or after function execution. It can have two properties:
4005-
* `before` - defines the amount of time (ISO 8601 duration format) to sleep before function invocation.
4006-
* `after` - defines the amount of time (ISO 8601 duration format) to sleep after function invocation.
4005+
* `before` - defines the amount of time (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep before function invocation.
4006+
* `after` - defines the amount of time (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep after function invocation.
40074007

40084008
Function invocation timeouts should be handled via the states [timeouts](#Workflow-Timeouts) definition.
40094009

@@ -4133,7 +4133,7 @@ Allows defining invocation of a function via event.
41334133
| --- | --- | --- | --- |
41344134
| [produceEventRef](#Event-Definition) | Reference to the unique name of a `produced` event definition. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
41354135
| [consumeEventRef](#Event-Definition) | Reference to the unique name of a `consumed` event definition. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | no |
4136-
| consumeEventTimeout | Maximum amount of time (ISO 8601 format) to wait for the consume event. If not defined it be set to the [actionExecutionTimeout](#Workflow-Timeout-Definition) | string | no |
4136+
| consumeEventTimeout | Maximum amount of time (ISO 8601 format literal or expression) to wait for the consume event. If not defined it be set to the [actionExecutionTimeout](#Workflow-Timeout-Definition) | string | no |
41374137
| data | If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by `produceEventRef`. If object type, a custom object to become the data (payload) of the event referenced by `produceEventRef`. | string or object | no |
41384138
| contextAttributes | Add additional event extension context attributes to the trigger/produced event | object | no |
41394139
| invoke | Specifies if the function should be invoked sync or async. Default is sync | enum | no |
@@ -4183,7 +4183,7 @@ to be used as payload of the event referenced by `produceEventRef`. If it is of
41834183
The `contextAttributes` property allows you to add one or more [extension context attributes](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#extension-context-attributes)
41844184
to the trigger/produced event.
41854185

4186-
The `consumeEventTimeout` property defines the maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the [actionExecutionTimeout](#Workflow-Timeout-Definition).
4186+
The `consumeEventTimeout` property defines the maximum amount of time (ISO 8601 format literal or expression) to wait for the result event. If not defined it should default to the [actionExecutionTimeout](#Workflow-Timeout-Definition).
41874187
If the event defined by the `consumeEventRef` property is not received in that set time, action invocation should raise an error
41884188
that can be handled in the states `onErrors` definition. In case the `consumeEventRef` is not defined, the `consumeEventTimeout` property is ignored.
41894189

@@ -4340,12 +4340,12 @@ For more information, see the [Workflow Error Handling](#Workflow-Error-Handling
43404340
| Parameter | Description | Type | Required |
43414341
| --- | --- | --- | --- |
43424342
| name | Unique retry strategy name | string | yes |
4343-
| delay | Time delay between retry attempts (ISO 8601 duration format) | string | no |
4343+
| delay | Time delay between retry attempts (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
43444344
| maxAttempts | Maximum number of retry attempts. Value of 1 means no retries are performed | string or number | yes |
4345-
| maxDelay | Maximum amount of delay between retry attempts (ISO 8601 duration format) | string | no |
4346-
| increment | Static duration which will be added to the delay between successive retries (ISO 8601 duration format) | string | no |
4345+
| maxDelay | Maximum amount of delay between retry attempts (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
4346+
| increment | Static duration which will be added to the delay between successive retries (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
43474347
| multiplier | Float value by which the delay is multiplied before each attempt. For example: "1.2" meaning that each successive delay is 20% longer than the previous delay. For example, if delay is 'PT10S', then the delay between the first and second attempts will be 10 seconds, and the delay before the third attempt will be 12 seconds. | float or string | no |
4348-
| jitter | If float type, maximum amount of random time added or subtracted from the delay between each retry relative to total delay (between 0.0 and 1.0). If string type, absolute maximum amount of random time added or subtracted from the delay between each retry (ISO 8601 duration format) | float or string | no |
4348+
| jitter | If float type, maximum amount of random time added or subtracted from the delay between each retry relative to total delay (between 0.0 and 1.0). If string type, absolute maximum amount of random time added or subtracted from the delay between each retry (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | float or string | no |
43494349

43504350
<details><summary><strong>Click to view example definition</strong></summary>
43514351
<p>
@@ -4389,9 +4389,9 @@ defined state [actions](#Action-Definition).
43894389
The `name` property specifies the unique name of the retry definition (strategy). This unique name
43904390
can be referred by workflow states [error definitions](#Error-Definition).
43914391

4392-
The `delay` property specifies the initial time delay between retry attempts (ISO 8601 duration format).
4392+
The `delay` property specifies the initial time delay between retry attempts (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration).
43934393

4394-
The `increment` property specifies a static duration which will be added to the delay between successive retries.
4394+
The `increment` property specifies a duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) which will be added to the delay between successive retries.
43954395
To explain this better, let's say we have the following retry definition:
43964396

43974397
```json
@@ -4441,7 +4441,7 @@ a `jitter` value of 0.3, a random amount of time between 0 and 1.8 (0.3 times 6)
44414441
from the calculated delay.
44424442

44434443
Alternatively, `jitter` may be defined as an absolute value specified as an ISO
4444-
8601 duration. This way, the maximum amount of random time added is fixed and
4444+
8601 duration (literal or expression). This way, the maximum amount of random time added is fixed and
44454445
will not increase as new attempts are made.
44464446

44474447
The `maxDelay` property determines the maximum amount of delay that is desired between retry attempts, and is applied
@@ -4922,7 +4922,7 @@ it with its `object` type which has the following properties:
49224922
| Parameter | Description | Type | Required |
49234923
| --- | --- | --- | --- |
49244924
| expression | Cron expression describing when the workflow instance should be created (automatically) | string | yes |
4925-
| validUntil | Specific date and time (ISO 8601 format) when the cron expression is no longer valid | string | no |
4925+
| validUntil | Specific date and time (ISO 8601 format, literal or expression producing it) when the cron expression is no longer valid | string | no |
49264926

49274927
<details><summary><strong>Click to view example definition</strong></summary>
49284928
<p>
@@ -4959,7 +4959,7 @@ validUntil: '2021-11-05T08:15:30-05:00'
49594959
The `expression` property is a a [cron expression](http://crontab.org/) which defines
49604960
when workflow instances should be created (automatically).
49614961

4962-
The `validUntil` property defines a date and time (using ISO 8601 format). When the
4962+
The `validUntil` property defines a date and time (using ISO 8601 format, literal or expression). When the
49634963
`validUntil` time is reached, the cron expression for instances creations of this workflow
49644964
should no longer be valid.
49654965

@@ -5653,11 +5653,11 @@ If `object` type, it is used to define the timeout definitions in-line and has t
56535653

56545654
| Parameter | Description | Type | Required |
56555655
| --- | --- | --- | --- |
5656-
| [workflowExecTimeout](#workflowexectimeout-definition) | Workflow execution timeout (ISO 8601 duration format) | string or object | no |
5657-
| [stateExecTimeout](#states-timeout-definition) | Workflow state execution timeout (ISO 8601 duration format) | string | no |
5658-
| actionExecTimeout | Actions execution timeout (ISO 8601 duration format) | string | no |
5659-
| [branchExecTimeout](#branch-timeout-definition) | Branch execution timeout (ISO 8601 duration format) | string | no |
5660-
| [eventTimeout](#event-timeout-definition) | Default timeout for consuming defined events (ISO 8601 duration format) | string | no |
5656+
| [workflowExecTimeout](#workflowexectimeout-definition) | Workflow execution timeout (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string or object | no |
5657+
| [stateExecTimeout](#states-timeout-definition) | Workflow state execution timeout (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
5658+
| actionExecTimeout | Actions execution timeout (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
5659+
| [branchExecTimeout](#branch-timeout-definition) | Branch execution timeout (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
5660+
| [eventTimeout](#event-timeout-definition) | Default timeout for consuming defined events (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | no |
56615661

56625662
The `eventTimeout` property defines the maximum amount of time to wait to consume defined events. If not specified it should default to
56635663
"unlimited".
@@ -5682,7 +5682,7 @@ If Object type it has the following format:
56825682

56835683
| Parameter | Description | Type | Required |
56845684
| --- | --- | --- | --- |
5685-
| duration | Timeout duration (ISO 8601 duration format) | string | yes |
5685+
| duration | Timeout duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) | string | yes |
56865686
| interrupt | If `false`, workflow instance is allowed to finish current execution. If `true`, current workflow execution is stopped immediately. Default is `false` | boolean | no |
56875687
| runBefore | Name of a workflow state to be executed before workflow instance is terminated | string | no |
56885688

@@ -5747,7 +5747,7 @@ timeout settings are available for each state type.
57475747
Workflow states timeouts cannot define the `workflowExecTimeout` property.
57485748

57495749
Workflow states can set their `stateExecTimeout` property inside the `timeouts` definition.
5750-
The value of this property is a time duration (ISO 8601 duration format).
5750+
The value of this property is a time duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration).
57515751
It must be a duration that's greater than zero and defines the total state execution timeout.
57525752
When this timeout is reached, state execution
57535753
should be stopped and can be handled as a timeout error in the states `onErrors` definition.

0 commit comments

Comments
 (0)