Skip to content

Commit 21d84a8

Browse files
author
Tihomir Surdilovic
authored
Simplify schedule and cron definitions (#260)
* simplify cron definition Signed-off-by: Tihomir Surdilovic <[email protected]> * simplified schedule definition Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent d8b27e5 commit 21d84a8

File tree

3 files changed

+82
-52
lines changed

3 files changed

+82
-52
lines changed

examples/README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,9 +2082,7 @@ Bidding is done via an online application and bids are received as events are as
20822082
"name": "StoreCarAuctionBid",
20832083
"type": "event",
20842084
"start": {
2085-
"schedule": {
2086-
"interval": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
2087-
}
2085+
"schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
20882086
},
20892087
"exclusive": true,
20902088
"onEvents": [
@@ -2125,8 +2123,7 @@ states:
21252123
- name: StoreCarAuctionBid
21262124
type: event
21272125
start:
2128-
schedule:
2129-
interval: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
2126+
schedule: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
21302127
exclusive: true
21312128
onEvents:
21322129
- eventRefs:
@@ -2208,9 +2205,7 @@ The results of the inbox service called is expected to be for example:
22082205
"type": "operation",
22092206
"start": {
22102207
"schedule": {
2211-
"cron": {
2212-
"expression": "0 0/15 * * * ?"
2213-
}
2208+
"cron": "0 0/15 * * * ?"
22142209
}
22152210
},
22162211
"actionMode": "sequential",
@@ -2260,8 +2255,7 @@ states:
22602255
type: operation
22612256
start:
22622257
schedule:
2263-
cron:
2264-
expression: 0 0/15 * * * ?
2258+
cron: 0 0/15 * * * ?
22652259
actionMode: sequential
22662260
actions:
22672261
- functionRef: checkInboxFunction

schema/workflow.json

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,28 @@
102102
],
103103
"definitions": {
104104
"crondef": {
105-
"type": "object",
106-
"properties": {
107-
"expression": {
105+
"oneOf": [
106+
{
108107
"type": "string",
109108
"description": "Repeating interval (cron expression) describing when the workflow instance should be created",
110109
"minLength": 1
111110
},
112-
"validUntil": {
113-
"type": "string",
114-
"description": "Specific date and time (ISO 8601 format) when the cron expression invocation is no longer valid"
111+
{
112+
"type": "object",
113+
"properties": {
114+
"expression": {
115+
"type": "string",
116+
"description": "Repeating interval (cron expression) describing when the workflow instance should be created",
117+
"minLength": 1
118+
},
119+
"validUntil": {
120+
"type": "string",
121+
"description": "Specific date and time (ISO 8601 format) when the cron expression invocation is no longer valid"
122+
}
123+
},
124+
"required": ["expression"]
115125
}
116-
}
126+
]
117127
},
118128
"exectimeout": {
119129
"type": "object",
@@ -1767,35 +1777,45 @@
17671777
]
17681778
},
17691779
"schedule": {
1770-
"type": "object",
1771-
"description": "Start state schedule definition",
1772-
"properties": {
1773-
"interval": {
1774-
"type": "string",
1775-
"description": "Time interval (ISO 8601 format) describing when workflow instances can be created."
1776-
},
1777-
"cron": {
1778-
"$ref": "#/definitions/crondef"
1779-
},
1780-
"directInvoke": {
1781-
"description": "Define if workflow instances can be created outside of the defined interval/cron",
1782-
"type": "boolean",
1783-
"default": false
1784-
},
1785-
"timezone": {
1786-
"type": "string",
1787-
"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."
1788-
}
1789-
},
17901780
"oneOf": [
17911781
{
1792-
"required": [
1793-
"interval"
1794-
]
1782+
"type": "string",
1783+
"description": "Time interval (ISO 8601 format) describing when workflow instances can be created.",
1784+
"minLength": 1
17951785
},
17961786
{
1797-
"required": [
1798-
"cron"
1787+
"type": "object",
1788+
"description": "Start state schedule definition",
1789+
"properties": {
1790+
"interval": {
1791+
"type": "string",
1792+
"description": "Time interval (ISO 8601 format) describing when workflow instances can be created.",
1793+
"minLength": 1
1794+
},
1795+
"cron": {
1796+
"$ref": "#/definitions/crondef"
1797+
},
1798+
"directInvoke": {
1799+
"description": "Define if workflow instances can be created outside of the defined interval/cron",
1800+
"type": "boolean",
1801+
"default": false
1802+
},
1803+
"timezone": {
1804+
"type": "string",
1805+
"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."
1806+
}
1807+
},
1808+
"oneOf": [
1809+
{
1810+
"required": [
1811+
"interval"
1812+
]
1813+
},
1814+
{
1815+
"required": [
1816+
"cron"
1817+
]
1818+
}
17991819
]
18001820
}
18011821
]

specification.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,18 +3083,15 @@ If the start definition is of type `object`, it has the following structure:
30833083

30843084
```json
30853085
{
3086-
"schedule": {
3087-
"interval": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
3088-
}
3086+
"schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
30893087
}
30903088
```
30913089

30923090
</td>
30933091
<td valign="top">
30943092

30953093
```yaml
3096-
schedule:
3097-
interval: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
3094+
schedule: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z
30983095
```
30993096

31003097
</td>
@@ -3157,6 +3154,17 @@ the needed events at the defined times to trigger workflow instance creation.
31573154

31583155
#### Schedule Definition
31593156

3157+
`Schedule` definition can have two types, either `string` or `object`.
3158+
If `string` type, it defines time interval describing when the workflow instance can be created.
3159+
This can be used as a short-cut definition when you don't need to define any other parameters, for example:
3160+
3161+
```json
3162+
"schedule": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z"
3163+
```
3164+
3165+
If you need to define the `cron`, `directInvoke` or the `timezone` parameters in your `schedule` definition, you can define
3166+
it with its `object` type which has the following properties:
3167+
31603168
| Parameter | Description | Type | Required |
31613169
| --- | --- | --- | --- |
31623170
| interval | Time interval describing when the workflow instance can be created (ISO 8601 time interval format). | string | yes if `cron` not defined |
@@ -3177,9 +3185,7 @@ the needed events at the defined times to trigger workflow instance creation.
31773185

31783186
```json
31793187
{
3180-
"cron": {
3181-
"expression": "0 0/15 * * * ?"
3182-
},
3188+
"cron": "0 0/15 * * * ?",
31833189
"directInvoke": true
31843190
}
31853191
```
@@ -3188,8 +3194,7 @@ the needed events at the defined times to trigger workflow instance creation.
31883194
<td valign="top">
31893195

31903196
```yaml
3191-
cron:
3192-
expression: 0 0/15 * * * ?
3197+
cron: 0 0/15 * * * ?
31933198
directInvoke: true
31943199
```
31953200

@@ -3226,6 +3231,17 @@ The `directInvoke` property defines if workflow instances are allowed to be crea
32263231

32273232
#### Cron Definition
32283233

3234+
`Cron` definition can have two types, either `string` or `object`.
3235+
If `string` type, it defines the repeating interval (cron expression) describing when the workflow instance should be created.
3236+
This can be used as a short-cut definition when you don't need to define any other parameters, for example:
3237+
3238+
```json
3239+
"cron": "0 15,30,45 * ? * *"
3240+
```
3241+
3242+
If you need to define the `validUntil` parameters in your `cron` definition, you can define
3243+
it with its `object` type which has the following properties:
3244+
32293245
| Parameter | Description | Type | Required |
32303246
| --- | --- | --- | --- |
32313247
| expression | Repeating interval (cron expression) describing when the workflow instance should be created | string | yes |

0 commit comments

Comments
 (0)