Skip to content

Commit 65f3036

Browse files
Merge pull request #833 from fjtirado/Fix_#686
[Fix #686] Remove sleep state
2 parents e8ed64b + df70655 commit 65f3036

File tree

4 files changed

+13
-122
lines changed

4 files changed

+13
-122
lines changed

examples/book-lending.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "1.0.0",
55
"specVersion": "0.8",
66
"start": "book-lending-request",
7+
"constants" : { "WAIT_BEFORE_POLL" : "PT2W"},
78
"states": [
89
{
910
"name": "book-lending-request",
@@ -100,10 +101,13 @@
100101
"bookid": "${ .book.id }",
101102
"lender": "${ .lender }"
102103
}
104+
},
105+
"sleep" : {
106+
"after" : "$CONST.WAIT_BEFORE_POLL"
103107
}
104108
}
105109
],
106-
"transition": "sleep-two-weeks"
110+
"transition": "get-book-status"
107111
},
108112
{
109113
"name": "cancel-request",
@@ -117,15 +121,12 @@
117121
"bookid": "${ .book.id }",
118122
"lender": "${ .lender }"
119123
}
124+
},
125+
"sleep" : {
126+
"after" : "$CONST.WAIT_BEFORE_POLL"
120127
}
121128
}
122129
],
123-
"transition": "sleep-two-weeks"
124-
},
125-
{
126-
"name": "sleep-two-weeks",
127-
"type": "sleep",
128-
"duration": "PT2W",
129130
"transition": "get-book-status"
130131
},
131132
{

examples/monitor-job.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@
4444
"stateDataFilter": {
4545
"output": "${ .jobuid }"
4646
},
47-
"transition": "wait-for-completion"
48-
},
49-
{
50-
"name": "wait-for-completion",
51-
"type": "sleep",
52-
"duration": "PT5S",
5347
"transition": "get-job-status"
5448
},
5549
{
@@ -67,6 +61,9 @@
6761
},
6862
"actionDataFilter": {
6963
"results": "${ .jobstatus }"
64+
},
65+
"sleep" : {
66+
"before": "PT5S"
7067
}
7168
}
7269
],
@@ -91,7 +88,7 @@
9188
}
9289
],
9390
"defaultCondition": {
94-
"transition": "wait-for-completion"
91+
"transition": "get-job-status"
9592
}
9693
},
9794
{

schema/workflow.json

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@
107107
"description": "State definitions",
108108
"items": {
109109
"anyOf": [
110-
{
111-
"title": "Sleep State",
112-
"$ref": "#/definitions/sleepstate"
113-
},
114110
{
115111
"title": "Event State",
116112
"$ref": "#/definitions/eventstate"
@@ -646,56 +642,6 @@
646642
"actions"
647643
]
648644
},
649-
"sleepstate": {
650-
"type": "object",
651-
"description": "Causes the workflow execution to sleep for a specified duration",
652-
"properties": {
653-
"name": {
654-
"type": "string",
655-
"description": "State name",
656-
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
657-
},
658-
"type": {
659-
"type": "string",
660-
"const": "sleep",
661-
"description": "State type"
662-
},
663-
"end": {
664-
"$ref": "#/definitions/end",
665-
"description": "State end definition"
666-
},
667-
"duration": {
668-
"type": "string",
669-
"description": "Duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep"
670-
},
671-
"transition": {
672-
"description": "Next transition of the workflow after the workflow sleep",
673-
"$ref": "#/definitions/transition"
674-
},
675-
"metadata": {
676-
"$ref": "common.json#/definitions/metadata"
677-
}
678-
},
679-
"additionalProperties": false,
680-
"oneOf": [
681-
{
682-
"required": [
683-
"name",
684-
"type",
685-
"duration",
686-
"end"
687-
]
688-
},
689-
{
690-
"required": [
691-
"name",
692-
"type",
693-
"duration",
694-
"transition"
695-
]
696-
}
697-
]
698-
},
699645
"eventstate": {
700646
"type": "object",
701647
"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",

specification.md

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
- [Event State](#event-state)
4242
- [Operation State](#operation-state)
4343
- [Switch State](#switch-state)
44-
- [Sleep State](#sleep-state)
4544
- [Parallel State](#parallel-state)
4645
- [Inject State](#inject-state)
4746
- [ForEach State](#foreach-state)
@@ -2279,7 +2278,6 @@ Serverless Workflow defines the following Workflow States:
22792278
| **[Event](#Event-State)** | Define events that trigger action execution | yes | yes | yes | yes | yes | no | yes | yes |
22802279
| **[Operation](#Operation-State)** | Execute one or more actions | no | yes | yes | yes | yes | no | yes | yes |
22812280
| **[Switch](#Switch-State)** | Define data-based or event-based workflow transitions | no | yes | no | yes | no | yes | yes | no |
2282-
| **[Sleep](#Sleep-State)** | Sleep workflow execution for a specific time duration | no | yes | no | yes | no | no | yes | yes |
22832281
| **[Parallel](#Parallel-State)** | Causes parallel execution of branches (set of states) | no | yes | no | yes | yes | no | yes | yes |
22842282
| **[Inject](#Inject-State)** | Inject static data into state data | no | yes | no | yes | no | no | yes | yes |
22852283
| **[ForEach](#ForEach-State)** | Parallel execution of states for each element of a data array | no | yes | no | yes | yes | no | yes | yes |
@@ -2607,57 +2605,6 @@ The `timeouts` property can be used to define state specific timeout settings. S
26072605
`stateExecTimeout` setting. If `eventConditions` is defined, the switch state can also define the
26082606
`eventTimeout` property. For more information on workflow timeouts reference the [Workflow Timeouts](#Workflow-Timeouts) section.
26092607

2610-
##### Sleep State
2611-
2612-
| Parameter | Description | Type | Required |
2613-
| --- | --- | --- | --- |
2614-
| name | Unique State name. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
2615-
| type | State type | string | yes |
2616-
| 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 |
2617-
| [transition](#Transitions) | Next transition of the workflow after the sleep | string or object | yes (if `end` is not defined) |
2618-
| [end](#End-Definition) | Is this state an end state | boolean or object | yes (if `transition` is not defined) |
2619-
2620-
<details><summary><strong>Click to view example definition</strong></summary>
2621-
<p>
2622-
2623-
<table>
2624-
<tr>
2625-
<th>JSON</th>
2626-
<th>YAML</th>
2627-
</tr>
2628-
<tr>
2629-
<td valign="top">
2630-
2631-
```json
2632-
{
2633-
"name": "sleep-five-seconds",
2634-
"type": "sleep",
2635-
"duration": "PT5S",
2636-
"transition": "get-job-status"
2637-
}
2638-
```
2639-
2640-
</td>
2641-
<td valign="top">
2642-
2643-
```yaml
2644-
name: sleep-five-seconds
2645-
type: sleep
2646-
duration: PT5S
2647-
transition: get-job-status
2648-
```
2649-
2650-
</td>
2651-
</tr>
2652-
</table>
2653-
2654-
</details>
2655-
2656-
Sleep state
2657-
suspends workflow execution for a given time duration. The delay is defined in its `duration` property using the ISO 8601
2658-
duration format. Note that ISO 8601 can be the result of evaluating an expression.
2659-
2660-
Note that `transition` and `end` properties are mutually exclusive, meaning that you cannot define both of them at the same time.
26612608
##### Parallel State
26622609

26632610
| Parameter | Description | Type | Required |
@@ -5739,7 +5686,7 @@ not obeyed in the workflow definition.
57395686

57405687
#### States Timeout Definition
57415688

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

0 commit comments

Comments
 (0)