Skip to content

[Fix #686] Remove sleep state #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions examples/book-lending.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "1.0.0",
"specVersion": "0.8",
"start": "book-lending-request",
"constants" : { "WAIT_BEFORE_POLL" : "PT2W"},
"states": [
{
"name": "book-lending-request",
Expand Down Expand Up @@ -101,10 +102,13 @@
"bookid": "${ .book.id }",
"lender": "${ .lender }"
}
},
"sleep" : {
"after" : "$CONST.WAIT_BEFORE_POLL"
}
}
],
"transition": "sleep-two-weeks"
"transition": "get-book-status"
},
{
"name": "cancel-request",
Expand All @@ -118,15 +122,12 @@
"bookid": "${ .book.id }",
"lender": "${ .lender }"
}
},
"sleep" : {
"after" : "$CONST.WAIT_BEFORE_POLL"
}
}
],
"transition": "sleep-two-weeks"
},
{
"name": "sleep-two-weeks",
"type": "sleep",
"duration": "PT2W",
"transition": "get-book-status"
},
{
Expand Down
11 changes: 4 additions & 7 deletions examples/monitor-job.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
"stateDataFilter": {
"output": "${ .jobuid }"
},
"transition": "wait-for-completion"
},
{
"name": "wait-for-completion",
"type": "sleep",
"duration": "PT5S",
"transition": "get-job-status"
},
{
Expand All @@ -68,6 +62,9 @@
},
"actionDataFilter": {
"results": "${ .jobstatus }"
},
"sleep" : {
"before": "PT5S"
}
}
],
Expand All @@ -92,7 +89,7 @@
}
],
"defaultCondition": {
"transition": "wait-for-completion"
"transition": "get-job-status"
}
},
{
Expand Down
54 changes: 0 additions & 54 deletions schema/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@
"description": "State definitions",
"items": {
"anyOf": [
{
"title": "Sleep State",
"$ref": "#/definitions/sleepstate"
},
{
"title": "Event State",
"$ref": "#/definitions/eventstate"
Expand Down Expand Up @@ -643,56 +639,6 @@
"actions"
]
},
"sleepstate": {
"type": "object",
"description": "Causes the workflow execution to sleep for a specified duration",
"properties": {
"name": {
"type": "string",
"description": "State name",
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
},
"type": {
"type": "string",
"const": "sleep",
"description": "State type"
},
"end": {
"$ref": "#/definitions/end",
"description": "State end definition"
},
"duration": {
"type": "string",
"description": "Duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep"
},
"transition": {
"description": "Next transition of the workflow after the workflow sleep",
"$ref": "#/definitions/transition"
},
"metadata": {
"$ref": "common.json#/definitions/metadata"
}
},
"additionalProperties": false,
"oneOf": [
{
"required": [
"name",
"type",
"duration",
"end"
]
},
{
"required": [
"name",
"type",
"duration",
"transition"
]
}
]
},
"eventstate": {
"type": "object",
"description": "This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel",
Expand Down
55 changes: 1 addition & 54 deletions specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
- [Event State](#event-state)
- [Operation State](#operation-state)
- [Switch State](#switch-state)
- [Sleep State](#sleep-state)
- [Parallel State](#parallel-state)
- [Inject State](#inject-state)
- [ForEach State](#foreach-state)
Expand Down Expand Up @@ -2289,7 +2288,6 @@ Serverless Workflow defines the following Workflow States:
| **[Event](#Event-State)** | Define events that trigger action execution | yes | yes | yes | yes | yes | no | yes | yes |
| **[Operation](#Operation-State)** | Execute one or more actions | no | yes | yes | yes | yes | no | yes | yes |
| **[Switch](#Switch-State)** | Define data-based or event-based workflow transitions | no | yes | no | yes | no | yes | yes | no |
| **[Sleep](#Sleep-State)** | Sleep workflow execution for a specific time duration | no | yes | no | yes | no | no | yes | yes |
| **[Parallel](#Parallel-State)** | Causes parallel execution of branches (set of states) | no | yes | no | yes | yes | no | yes | yes |
| **[Inject](#Inject-State)** | Inject static data into state data | no | yes | no | yes | no | no | yes | yes |
| **[ForEach](#ForEach-State)** | Parallel execution of states for each element of a data array | no | yes | no | yes | yes | no | yes | yes |
Expand Down Expand Up @@ -2617,57 +2615,6 @@ The `timeouts` property can be used to define state specific timeout settings. S
`stateExecTimeout` setting. If `eventConditions` is defined, the switch state can also define the
`eventTimeout` property. For more information on workflow timeouts reference the [Workflow Timeouts](#Workflow-Timeouts) section.

##### Sleep State

| Parameter | Description | Type | Required |
| --- | --- | --- | --- |
| name | Unique State name. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
| type | State type | string | yes |
| 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 |
| [transition](#Transitions) | Next transition of the workflow after the sleep | string or object | yes (if `end` is not defined) |
| [end](#End-Definition) | Is this state an end state | boolean or object | yes (if `transition` is not defined) |

<details><summary><strong>Click to view example definition</strong></summary>
<p>

<table>
<tr>
<th>JSON</th>
<th>YAML</th>
</tr>
<tr>
<td valign="top">

```json
{
"name": "sleep-five-seconds",
"type": "sleep",
"duration": "PT5S",
"transition": "get-job-status"
}
```

</td>
<td valign="top">

```yaml
name: sleep-five-seconds
type: sleep
duration: PT5S
transition: get-job-status
```

</td>
</tr>
</table>

</details>

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

Note that `transition` and `end` properties are mutually exclusive, meaning that you cannot define both of them at the same time.
##### Parallel State

| Parameter | Description | Type | Required |
Expand Down Expand Up @@ -5739,7 +5686,7 @@ not obeyed in the workflow definition.

#### States Timeout Definition

All workflow states except Sleep and Inject States can define the `timeouts` property and can define different timeout
All workflow states except Inject State can define the `timeouts` property and can define different timeout
settings depending on their state type.
Please reference each [workflow state definitions](#Workflow-States) for more information on which
timeout settings are available for each state type.
Expand Down