Skip to content

Commit dfc7de7

Browse files
jorgenjJorgen Johnson
andauthored
Updates to schedule definition (#281)
* Remove directInvoke Signed-off-by: Jorgen Johnson <[email protected]> * Redefine schedule.interval to be about scheduled execution of workflows (rather than about limiting when workflows can be invoked) Signed-off-by: Jorgen Johnson <[email protected]> * Integrate PR feedback Signed-off-by: Jorgen Johnson <[email protected]> Co-authored-by: Jorgen Johnson <[email protected]>
1 parent 486438d commit dfc7de7

File tree

5 files changed

+38
-58
lines changed

5 files changed

+38
-58
lines changed

comparisons/comparison-bpmn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ name: Execution Timeout Workflow
259259
version: '1.0'
260260
start: Purchase Parts
261261
execTimeout:
262-
interval: PT7D
262+
duration: PT7D
263263
interrupt: true
264264
runBefore: Handle timeout
265265
states:

examples/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ Bidding is done via an online application and bids are received as events are as
20662066
"description": "Store a single bid whole the car auction is active",
20672067
"start": {
20682068
"stateName": "StoreCarAuctionBid",
2069-
"schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
2069+
"schedule": "R/PT2H"
20702070
},
20712071
"functions": [
20722072
{
@@ -2115,7 +2115,7 @@ name: Car Auction Bidding Workflow
21152115
description: Store a single bid whole the car auction is active
21162116
start:
21172117
stateName: StoreCarAuctionBid
2118-
schedule: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
2118+
schedule: R/PT2H
21192119
functions:
21202120
- name: StoreBidFunction
21212121
operation: http://myapis.org/carauctionapi.json#storeBid
@@ -2827,7 +2827,7 @@ This example shows the use of the workflow [execTimeout definition](../specifica
28272827
"version": "1.0",
28282828
"start": "StartNewOrder",
28292829
"execTimeout": {
2830-
"interval": "PT30D",
2830+
"duration": "PT30D",
28312831
"interrupt": true,
28322832
"runBefore": "CancelOrder"
28332833
},
@@ -2986,7 +2986,7 @@ name: Purchase Order Workflow
29862986
version: '1.0'
29872987
start: StartNewOrder
29882988
execTimeout:
2989-
interval: PT30D
2989+
duration: PT30D
29902990
interrupt: true
29912991
runBefore: CancelOrder
29922992
states:
@@ -3107,7 +3107,7 @@ the data for an hour, send report, and so on.
31073107
"version": "1.0",
31083108
"start": "ConsumeReading",
31093109
"execTimeout": {
3110-
"interval": "PT1H",
3110+
"duration": "PT1H",
31113111
"runBefore": "GenerateReport"
31123112
},
31133113
"keepActive": true,
@@ -3194,7 +3194,7 @@ name: Room Temp and Humidity Workflow
31943194
version: '1.0'
31953195
start: ConsumeReading
31963196
execTimeout:
3197-
interval: PT1H
3197+
duration: PT1H
31983198
runBefore: GenerateReport
31993199
keepActive: true
32003200
states:

roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ _Status description:_
3737
| ✔️| Change function definition 'parameters' to 'arguments' | [spec doc](../specification.md) |
3838
| ✔️| Replace JsonPath with jq | [spec doc](../specification.md) |
3939
| ✔️| Update start definition (move to top-level worklow param) | [spec doc](../specification.md) |
40+
| ✔️| Updated schedule definition | [spec doc](../specification.md) |
4041
| 🚩 | Workflow invocation bindings | |
4142
| 🚩 | CE Subscriptions & Discovery | |
4243
| 🚩 | Error types | [issue](https://github.com/serverlessworkflow/specification/issues/200) |

schema/workflow.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@
138138
"exectimeout": {
139139
"type": "object",
140140
"properties": {
141-
"interval": {
141+
"duration": {
142142
"type": "string",
143-
"description": "Timeout interval (ISO 8601 duration format)",
143+
"description": "Timeout duration (ISO 8601 duration format)",
144144
"minLength": 1
145145
},
146146
"interrupt": {
@@ -155,7 +155,7 @@
155155
}
156156
},
157157
"required": [
158-
"interval"
158+
"duration"
159159
]
160160
},
161161
"transition": {
@@ -1550,7 +1550,7 @@
15501550
"minLength": 1
15511551
},
15521552
"schedule": {
1553-
"description": "Define the time/repeating intervals or cron at which workflow instances can/should be started",
1553+
"description": "Define the time/repeating intervals or cron at which workflow instances should be automatically started.",
15541554
"$ref": "#/definitions/schedule"
15551555
}
15561556
},
@@ -1565,7 +1565,7 @@
15651565
"oneOf": [
15661566
{
15671567
"type": "string",
1568-
"description": "Time interval (can be repeating) described with ISO 8601 format. Declares when workflow instances can be created.",
1568+
"description": "Time interval (must be repeating interval) described with ISO 8601 format. Declares when workflow instances will be automatically created. (UTC timezone is assumed)",
15691569
"minLength": 1
15701570
},
15711571
{
@@ -1574,20 +1574,15 @@
15741574
"properties": {
15751575
"interval": {
15761576
"type": "string",
1577-
"description": "Time interval (ISO 8601 format) describing when workflow instances can be created.",
1577+
"description": "Time interval (must be repeating interval) described with ISO 8601 format. Declares when workflow instances will be automatically created.",
15781578
"minLength": 1
15791579
},
15801580
"cron": {
15811581
"$ref": "#/definitions/crondef"
15821582
},
1583-
"directInvoke": {
1584-
"description": "Define if workflow instances can be created outside of the defined interval/cron",
1585-
"type": "boolean",
1586-
"default": false
1587-
},
15881583
"timezone": {
15891584
"type": "string",
1590-
"description": "Timezone name used to evaluate the cron expression. Not used for interval as timezone can be specified there directly. If not specified, should default to local machine timezone."
1585+
"description": "Timezone name used to evaluate the interval & cron-expression. (default: UTC)"
15911586
}
15921587
},
15931588
"oneOf": [

specification.md

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ You can reference the [specification examples](#Examples) to see the `keepActive
728728

729729
| Parameter | Description | Type | Required |
730730
| --- | --- | --- | --- |
731-
| interval | Timeout interval (ISO 8601 duration format) | string | yes |
731+
| duration | Timeout duration (ISO 8601 duration format) | string | yes |
732732
| interrupt | If `false`, workflow instance is allowed to finish current execution. If `true`, current workflow execution is stopped immediately. Default is `false` | boolean | no |
733733
| runBefore | Name of a workflow state to be executed before workflow instance is terminated | string | no |
734734

@@ -765,7 +765,7 @@ runBefore: createandsendreport
765765

766766
</details>
767767

768-
The `interval` property defines the time interval of the execution timeout. Once a workflow instance is created,
768+
The `duration` property defines the time duration of the execution timeout. Once a workflow instance is created,
769769
and the amount of the defined time is reached, the workflow instance should be terminated.
770770

771771
The `interrupt` property defines if the currently running instance should be allowed to finish its current
@@ -3107,7 +3107,7 @@ If the start definition is of type `object`, it has the following structure:
31073107
| Parameter | Description | Type | Required |
31083108
| --- | --- | --- | --- |
31093109
| stateName | Name of the starting workflow state | object | yes |
3110-
| [schedule](#Schedule-Definition) | Define the time/repeating intervals or cron at which workflow instances can/should be started | object | yes |
3110+
| [schedule](#Schedule-Definition) | Define the time/repeating intervals or cron at which workflow instances should be automatically started. | object | yes |
31113111

31123112
<details><summary><strong>Click to view example definition</strong></summary>
31133113
<p>
@@ -3150,19 +3150,10 @@ If `string` type, it defines the name of the workflow starting state.
31503150
If `object` type, it provides the ability to set the workflow starting state name, as well as the `schedule` property.
31513151

31523152
The `schedule` property allows to define scheduled workflow instance creation.
3153-
Scheduled starts have two different choices. You can define time-based intervals during which workflow instances are **allowed**
3154-
to be created (can be repeating), or cron-based times at which a workflow instance **should** be created (automatically).
3153+
Scheduled starts have two different choices. You can define a repeating interval or cron-based schedule at which a workflow
3154+
instance **should** be created (automatically).
31553155

3156-
To better explain interval-based scheduled starts, let's say
3157-
we have a workflow that orchestrates an online auction and should be "available" only from when the auction starts until it ends.
3158-
Customer bids should only be allowed during this time interval. Bids made before or after the defined time interval should not be allowed.
3159-
3160-
There are two cases to discuss when dealing with interval-based scheduled starts:
3161-
3162-
1. **Starting States in [Parallel](#Parallel-State) state [branches](#parallel-state-branch)**: if a state in a parallel state branch defines a scheduled start state that is not "active" at the time the branch is executed, the parent workflow should not wait until it becomes active, and just complete the execution of the branch.
3163-
2. **Starting states in [SubFlow](#SubFlow-State) states**: if a state in a workflow definition (referenced by SubFlow state) defines a scheduled start state that is not "active" at the time the SubFlow state is executed, the parent workflow should not wait until it becomes active, and just complete the execution of the SubFlow state.
3164-
3165-
You can also define cron-based scheduled starts, which allow to define periodically started workflow instances based on a [cron](http://crontab.org/) definition.
3156+
You can also define cron-based scheduled starts, which allows you to specify periodically started workflow instances based on a [cron](http://crontab.org/) definition.
31663157
Cron-based scheduled starts can handle absolute time intervals (i.e., not calculated in respect to some particular point in time).
31673158
One use case for cron-based scheduled starts is a workflow that performs periodical data batch processing.
31683159
In this case we could use a cron definition
@@ -3192,22 +3183,21 @@ the needed events at the defined times to trigger workflow instance creation.
31923183
#### Schedule Definition
31933184

31943185
`Schedule` definition can have two types, either `string` or `object`.
3195-
If `string` type, it defines time interval describing when the workflow instance can be created.
3186+
If `string` type, it defines time interval describing when the workflow instance should be automatically created.
31963187
This can be used as a short-cut definition when you don't need to define any other parameters, for example:
31973188

31983189
```json
3199-
"schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
3190+
"schedule": "R/PT2H"
32003191
```
32013192

3202-
If you need to define the `cron`, `directInvoke` or the `timezone` parameters in your `schedule` definition, you can define
3193+
If you need to define the `cron` or the `timezone` parameters in your `schedule` definition, you can define
32033194
it with its `object` type which has the following properties:
32043195

32053196
| Parameter | Description | Type | Required |
32063197
| --- | --- | --- | --- |
3207-
| interval | Time interval (can be repeating) described with ISO 8601 format. Declares when workflow instances can be created | string | yes if `cron` not defined |
3198+
| interval | Time interval (must be repeating interval) described with ISO 8601 format. Declares when workflow instances will be automatically created. | string | yes if `cron` not defined |
32083199
| [cron](#Cron-Definition) | Cron expression defining when workflow instances should be created (automatically) | object | yes if `interval` not defined |
3209-
| directInvoke | Defines if workflow instances can be created outside of the interval/cron interval. Default value is `false` | boolean | no |
3210-
| timezone | Timezone name (for example "America/Los_Angeles") used to evaluate the cron expression against. Not used for `interval` property as timezone can be specified there directly. If not specified, should default to local machine timezone | string | no |
3200+
| timezone | Timezone name used to evaluate the interval & cron-expression. If the interval specifies a date-time w/ timezone then proper timezone conversion will be applied. (default: UTC). | string | no |
32113201

32123202
<details><summary><strong>Click to view example definition</strong></summary>
32133203
<p>
@@ -3222,8 +3212,7 @@ it with its `object` type which has the following properties:
32223212

32233213
```json
32243214
{
3225-
"cron": "0 0/15 * * * ?",
3226-
"directInvoke": true
3215+
"cron": "0 0/15 * * * ?"
32273216
}
32283217
```
32293218

@@ -3232,7 +3221,6 @@ it with its `object` type which has the following properties:
32323221

32333222
```yaml
32343223
cron: 0 0/15 * * * ?
3235-
directInvoke: true
32363224
```
32373225

32383226
</td>
@@ -3241,31 +3229,27 @@ directInvoke: true
32413229

32423230
</details>
32433231

3244-
The `interval` property uses the ISO 8601 time interval format (can be repeating) to describe when workflow instances are allowed be created.
3245-
There is a number of ways to express the time interval:
3232+
The `interval` property uses the ISO 8601 time repeating interval format to describe when workflow instances will be automatically created.
3233+
There are a number of supported ways to express the repeating interval:
32463234

3247-
1. **Start** + **End**: Defines the start and end time, for example "2020-03-20T13:00:00Z/2021-05-11T15:30:00Z", meaning workflow instances can be
3248-
created from March 20th 2020 at 1PM UTC until May 11th 2021 at 3:30pm UTC.
3249-
2. **Start** + **Duration**: Defines the start time and the duration, for example: "2020-03-20T13:00:00Z/P1Y2M10DT2H30M", meaning workflow instances can be created
3250-
from March 20th 2020 at 1pm UTC and continue to do so for 1 year, 2 months, 10 days 2 hours and 30 minutes.
3251-
3. **Duration** + **End**: Defines the duration and an end, for example: "P1Y2M10DT2H30M/2020-05-11T15:30:00Z", meaning that workflow instances can be created from
3252-
when the first instance is created until 1 year, 2 months, 10 days 2 hours and 30 minutes from that time, or until May 11th 2020 at 3:30PM UTC, whichever comes first.
3253-
4. **Duration**: Defines the duration only, for example: ""P1Y2M10DT2H30M"", meaning workflow instances can be created for 1 year, 2 months, 10 days 2 hours and 30 minutes
3254-
from the time the first instance is created.
3235+
1. `R/<Start>/<Duration>`: Defines the start time and a duration, for example: "R/2020-03-20T13:00:00Z/PT2H", meaning workflow
3236+
instances will be automatically created every 2 hours starting from March 20th 2020 at 1pm UTC.
3237+
2. `R/<Duration>/<End>`: Defines a duration and an end, for example: "R/PT2H/2020-05-11T15:30:00Z", meaning that workflow instances will be
3238+
automatically created every 2 hours until until May 11th 2020 at 3:30PM UTC.
3239+
3. `R/<Duration>`: Defines a duration only, for example: "R/PT2H", meaning workflow instances will be automatically created every 2 hours.
32553240

32563241
The `cron` property uses a [cron expression](http://crontab.org/)
3257-
to describe a repeating interval upon which a workflow instance should be created (automatically).
3242+
to describe a repeating interval upon which a workflow instance should be created automatically.
32583243
For more information see the [cron definition](#Cron-Definition) section.
32593244

3260-
The `timezone` property is used to define a time zone name to evaluate the cron expression against. If not specified, it should default to the local
3261-
machine time zone. See [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for a list of timezone names.
3245+
The `timezone` property is used to define a time zone name to evaluate the cron or interval expression against. If not specified, it should default
3246+
to UTC time zone. See [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for a list of timezone names. For ISO 8601 date time
3247+
values in `interval` or `cron.validUntil`, runtimes should treat `timezone` as the 'local time' (UTC if `interval` is not defined by the user).
32623248

32633249
Note that when the workflow starting state is an [Event](#Event-State)
32643250
defining cron-based scheduled starts for the runtime implementations would mean that there needs to be an event service that issues
32653251
the needed events at the defined times to trigger workflow instance creation.
32663252

3267-
The `directInvoke` property defines if workflow instances are allowed to be created outside of the defined interval or cron expression.
3268-
32693253
#### Cron Definition
32703254

32713255
`Cron` definition can have two types, either `string` or `object`.

0 commit comments

Comments
 (0)