diff --git a/examples/book-lending.json b/examples/book-lending.json index fcb6672d..e143eccc 100644 --- a/examples/book-lending.json +++ b/examples/book-lending.json @@ -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", @@ -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", @@ -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" }, { diff --git a/examples/monitor-job.json b/examples/monitor-job.json index 75142e8d..d9b195d1 100644 --- a/examples/monitor-job.json +++ b/examples/monitor-job.json @@ -45,12 +45,6 @@ "stateDataFilter": { "output": "${ .jobuid }" }, - "transition": "wait-for-completion" - }, - { - "name": "wait-for-completion", - "type": "sleep", - "duration": "PT5S", "transition": "get-job-status" }, { @@ -68,6 +62,9 @@ }, "actionDataFilter": { "results": "${ .jobstatus }" + }, + "sleep" : { + "before": "PT5S" } } ], @@ -92,7 +89,7 @@ } ], "defaultCondition": { - "transition": "wait-for-completion" + "transition": "get-job-status" } }, { diff --git a/schema/workflow.json b/schema/workflow.json index 61e6c47b..11d659aa 100644 --- a/schema/workflow.json +++ b/schema/workflow.json @@ -113,10 +113,6 @@ "description": "State definitions", "items": { "anyOf": [ - { - "title": "Sleep State", - "$ref": "#/definitions/sleepstate" - }, { "title": "Event State", "$ref": "#/definitions/eventstate" @@ -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", diff --git a/specification.md b/specification.md index ea4d2ef1..2dd4fb3e 100644 --- a/specification.md +++ b/specification.md @@ -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) @@ -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 | @@ -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) | - -
Click to view example definition -

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

- -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 | @@ -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.