Skip to content

Commit df70655

Browse files
committed
[Fix #686] Remove sleep state
Removing sleep state, as it is redundant with sleep after and before Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
1 parent 3b6f976 commit df70655

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
@@ -5,6 +5,7 @@
55
"version": "1.0.0",
66
"specVersion": "0.8",
77
"start": "book-lending-request",
8+
"constants" : { "WAIT_BEFORE_POLL" : "PT2W"},
89
"states": [
910
{
1011
"name": "book-lending-request",
@@ -101,10 +102,13 @@
101102
"bookid": "${ .book.id }",
102103
"lender": "${ .lender }"
103104
}
105+
},
106+
"sleep" : {
107+
"after" : "$CONST.WAIT_BEFORE_POLL"
104108
}
105109
}
106110
],
107-
"transition": "sleep-two-weeks"
111+
"transition": "get-book-status"
108112
},
109113
{
110114
"name": "cancel-request",
@@ -118,15 +122,12 @@
118122
"bookid": "${ .book.id }",
119123
"lender": "${ .lender }"
120124
}
125+
},
126+
"sleep" : {
127+
"after" : "$CONST.WAIT_BEFORE_POLL"
121128
}
122129
}
123130
],
124-
"transition": "sleep-two-weeks"
125-
},
126-
{
127-
"name": "sleep-two-weeks",
128-
"type": "sleep",
129-
"duration": "PT2W",
130131
"transition": "get-book-status"
131132
},
132133
{

examples/monitor-job.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545
"stateDataFilter": {
4646
"output": "${ .jobuid }"
4747
},
48-
"transition": "wait-for-completion"
49-
},
50-
{
51-
"name": "wait-for-completion",
52-
"type": "sleep",
53-
"duration": "PT5S",
5448
"transition": "get-job-status"
5549
},
5650
{
@@ -68,6 +62,9 @@
6862
},
6963
"actionDataFilter": {
7064
"results": "${ .jobstatus }"
65+
},
66+
"sleep" : {
67+
"before": "PT5S"
7168
}
7269
}
7370
],
@@ -92,7 +89,7 @@
9289
}
9390
],
9491
"defaultCondition": {
95-
"transition": "wait-for-completion"
92+
"transition": "get-job-status"
9693
}
9794
},
9895
{

schema/workflow.json

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@
113113
"description": "State definitions",
114114
"items": {
115115
"anyOf": [
116-
{
117-
"title": "Sleep State",
118-
"$ref": "#/definitions/sleepstate"
119-
},
120116
{
121117
"title": "Event State",
122118
"$ref": "#/definitions/eventstate"
@@ -643,56 +639,6 @@
643639
"actions"
644640
]
645641
},
646-
"sleepstate": {
647-
"type": "object",
648-
"description": "Causes the workflow execution to sleep for a specified duration",
649-
"properties": {
650-
"name": {
651-
"type": "string",
652-
"description": "State name",
653-
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
654-
},
655-
"type": {
656-
"type": "string",
657-
"const": "sleep",
658-
"description": "State type"
659-
},
660-
"end": {
661-
"$ref": "#/definitions/end",
662-
"description": "State end definition"
663-
},
664-
"duration": {
665-
"type": "string",
666-
"description": "Duration (literal ISO 8601 duration format or expression which evaluation results in an ISO 8601 duration) to sleep"
667-
},
668-
"transition": {
669-
"description": "Next transition of the workflow after the workflow sleep",
670-
"$ref": "#/definitions/transition"
671-
},
672-
"metadata": {
673-
"$ref": "common.json#/definitions/metadata"
674-
}
675-
},
676-
"additionalProperties": false,
677-
"oneOf": [
678-
{
679-
"required": [
680-
"name",
681-
"type",
682-
"duration",
683-
"end"
684-
]
685-
},
686-
{
687-
"required": [
688-
"name",
689-
"type",
690-
"duration",
691-
"transition"
692-
]
693-
}
694-
]
695-
},
696642
"eventstate": {
697643
"type": "object",
698644
"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)
@@ -2289,7 +2288,6 @@ Serverless Workflow defines the following Workflow States:
22892288
| **[Event](#Event-State)** | Define events that trigger action execution | yes | yes | yes | yes | yes | no | yes | yes |
22902289
| **[Operation](#Operation-State)** | Execute one or more actions | no | yes | yes | yes | yes | no | yes | yes |
22912290
| **[Switch](#Switch-State)** | Define data-based or event-based workflow transitions | no | yes | no | yes | no | yes | yes | no |
2292-
| **[Sleep](#Sleep-State)** | Sleep workflow execution for a specific time duration | no | yes | no | yes | no | no | yes | yes |
22932291
| **[Parallel](#Parallel-State)** | Causes parallel execution of branches (set of states) | no | yes | no | yes | yes | no | yes | yes |
22942292
| **[Inject](#Inject-State)** | Inject static data into state data | no | yes | no | yes | no | no | yes | yes |
22952293
| **[ForEach](#ForEach-State)** | Parallel execution of states for each element of a data array | no | yes | no | yes | yes | no | yes | yes |
@@ -2617,57 +2615,6 @@ The `timeouts` property can be used to define state specific timeout settings. S
26172615
`stateExecTimeout` setting. If `eventConditions` is defined, the switch state can also define the
26182616
`eventTimeout` property. For more information on workflow timeouts reference the [Workflow Timeouts](#Workflow-Timeouts) section.
26192617

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

26732620
| 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)