Skip to content

Commit 37d70f5

Browse files
[0.7.x] Update commits to master branch (#444)
* Rename Delay state to Sleep state and rename timeDelay to duration property (#439) Signed-off-by: Tihomir Surdilovic <[email protected]> * Adding sleep object type prop to action definitions (#440) * Adding sleepBefore and sleepAfter to function definitions Signed-off-by: Tihomir Surdilovic <[email protected]> * moved props from functionDef to actionDef Signed-off-by: Tihomir Surdilovic <[email protected]> * updated roadmap Signed-off-by: Tihomir Surdilovic <[email protected]> * created 'sleep' type instead of individual props Signed-off-by: Tihomir Surdilovic <[email protected]> * Update specification.md Co-authored-by: Ricardo Zanini <[email protected]> * Update specification.md Co-authored-by: Ricardo Zanini <[email protected]> Co-authored-by: Ricardo Zanini <[email protected]> * Fix Car Vitals example (#443) Signed-off-by: Tihomir Surdilovic <[email protected]> * Adding rate limiting extension (#442) * Adding rate limiting extension Signed-off-by: Tihomir Surdilovic <[email protected]> * update readme Signed-off-by: Tihomir Surdilovic <[email protected]> * Foreach State - adding sequential exec option and batchSize for paral… (#441) * Foreach State - adding sequential exec option and batchSize for parallel exec option Signed-off-by: Tihomir Surdilovic <[email protected]> * updated roadmap Signed-off-by: Tihomir Surdilovic <[email protected]> * Update specification.md Co-authored-by: Ricardo Zanini <[email protected]> * Update specification.md Co-authored-by: Ricardo Zanini <[email protected]> * Update specification.md Co-authored-by: Ricardo Zanini <[email protected]> Co-authored-by: Ricardo Zanini <[email protected]> Co-authored-by: Ricardo Zanini <[email protected]>
1 parent 4eaa0a8 commit 37d70f5

File tree

10 files changed

+454
-319
lines changed

10 files changed

+454
-319
lines changed

examples/README.md

Lines changed: 155 additions & 279 deletions
Large diffs are not rendered by default.

extensions/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ Click on the `Extension Id` link to see detailed explanation of the extension.
1313
| Extension Id | Description | Json Schema |
1414
| --- | --- | --- |
1515
| [kpi](kpi.md) | Define workflow key performance indicators (KPIs) | [kpi.json](../schema/extensions/kpi.json) |
16+
| [ratelimiting](ratelimiting.md) | Define numerous rate limiting options for a workflow per single or all instances | [ratelimiting.json](../schema/extensions/ratelimiting.json) |
1617

extensions/kpi.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ KPIs can be added for the model:
3434
| --- | --- | --- | --- |
3535
| extensionid | Unique extension Id (default is 'workflow-kpi-extension') | string | yes |
3636
| workflowid | Workflow definition unique identifier (workflow id property) | string | yes |
37+
| workflowVersions | Workflow versions. If not defined, applies to all workflow instances (regardless of their associated workflow version) | array | no |
3738
| [workflow](#Workflow-KPIs-Definition) | Workflow definition KPIs | object | no |
3839
| [events](#Event-KPIs-Definition) | Workflow event definitions KPIs | array | no |
3940
| [functions](#Function-KPIs-Definition) | Workflow function definitions KPIs | array | no |

extensions/ratelimiting.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Extensions - Rate Limiting
2+
3+
## Table of Contents
4+
5+
- [Introduction](#Introduction)
6+
- [Extension Definition](#Extension-Definition)
7+
- [Workflow KPIs Definition](#Workflow-KPIs-Definition)
8+
- [Example](#Example)
9+
10+
## Introduction
11+
12+
Out workflows can execute numerous downstream services. Rate limiting can be used to protect these
13+
downstream services from flooding. In addition, rate limiting can help us keep our cost
14+
at a desired rate in cases where downstream service invocations have an associated cost factor.
15+
16+
## Extension Definition
17+
18+
| Parameter | Description | Type | Required |
19+
| --- | --- | --- | --- |
20+
| extensionid | Unique extension Id (default is 'workflow-kpi-extension') | string | yes |
21+
| workflowid | Workflow definition unique identifier (workflow id property) | string | yes |
22+
| workflowVersions | Workflow versions. If not defined, applies to all workflow instances (regardless of their associated workflow version) | array | no |
23+
| [singleInstance](#Single-Instance-Definition) | Rate limits per single workflow instance | object | no |
24+
| [allInstances](#All-Instances-Definition) | Rate limits per all workflow instances | object | no |
25+
26+
### Single Instance Definition
27+
28+
| Parameter | Description | Type | Required |
29+
| --- | --- | --- | --- |
30+
| maxActionsPerSecond | Sets the rate limiting on number of actions that can be executed per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means you want workflow actions should be executed once every 10 seconds. Default zero value means 'unlimited'| number | no |
31+
| maxConcurrentActions | Maximum number of actions that can be executed in parallel | string | no |
32+
| maxProducedEventsPerSecond |Sets the rate limiting on number of events that can be produced per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means workflow can produce events once every 10 seconds. Default zero value means 'unlimited' | string | no |
33+
| maxStates | Maximum number of workflow states that should be executed. Default is zero, meaning unlimited. | string | no |
34+
| maxTransitions | Maximum number of workflow transitions that should be executed. Default is zero, meaning unlimited. | string | no |
35+
36+
### All Instances Definition
37+
38+
| Parameter | Description | Type | Required |
39+
| --- | --- | --- | --- |
40+
| maxActionsPerSecond | Sets the rate limiting on number of actions that can be executed per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means you want workflow actions should be executed once every 10 seconds. Default zero value means 'unlimited'| number | no |
41+
| maxConcurrentActions | Maximum number of actions that can be executed in parallel | string | no |
42+
| maxProducedEventsPerSecond |Sets the rate limiting on number of events that can be produced per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means workflow can produce events once every 10 seconds. Default zero value means 'unlimited' | string | no |
43+
| maxStates | Maximum number of workflow states that should be executed. Default is zero, meaning unlimited. | string | no |
44+
| maxTransitions | Maximum number of workflow transitions that should be executed. Default is zero, meaning unlimited. | string | no |
45+
46+
## Example
47+
48+
The following example shows a workflow definition on the left and
49+
an associated sample Rate Limiting extension definition on the right.
50+
51+
<table>
52+
<tr>
53+
<th>Workflow</th>
54+
<th>Rate Limiting Extension</th>
55+
</tr>
56+
<tr>
57+
<td valign="top">
58+
59+
```yaml
60+
id: processapplication
61+
name: Process Application
62+
version: '1.0'
63+
specVersion: '0.7'
64+
start: ProcessNewApplication
65+
states:
66+
- name: ProcessNewApplication
67+
type: event
68+
onEvents:
69+
- eventRefs:
70+
- ApplicationReceivedEvent
71+
actions:
72+
- functionRef: processApplicationFunction
73+
- functionRef: acceptApplicantFunction
74+
- functionRef: depositFeesFunction
75+
end:
76+
produceEvents:
77+
- eventRef: NotifyApplicantEvent
78+
functions:
79+
- name: processApplicationFunction
80+
operation: file://myservice.json#process
81+
- name: acceptApplicantFunction
82+
operation: file://myservice.json#accept
83+
- name: depositFeesFunction
84+
operation: file://myservice.json#deposit
85+
events:
86+
- name: ApplicationReceivedEvent
87+
type: application
88+
source: "/applications/new"
89+
- name: NotifyApplicantEvent
90+
type: notifications
91+
source: "/applicants/notify"
92+
```
93+
94+
</td>
95+
<td valign="top">
96+
97+
```yaml
98+
extensionid: workflow-ratelimiting-extension
99+
workflowid: processapplication
100+
singleInstance:
101+
maxActionsPerSecond: 0.1
102+
maxConcurrentActions: 200
103+
maxProducedEventsPerSecond: 2
104+
maxStates: '1000'
105+
maxTransitions: '1000'
106+
allInstances:
107+
maxActionsPerSecond: 1
108+
maxConcurrentActions: 500
109+
maxProducedEventsPerSecond: 20
110+
maxStates: '10000'
111+
maxTransitions: '10000'
112+
113+
```
114+
115+
</td>
116+
</tr>
117+
</table>
-161 KB
Loading

roadmap/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ _Status description:_
4040
| ✔️| Temporarily removed `waitForCompletion` for subflows | [spec doc](../specification.md) |
4141
| ✔️| Added function definition support for OData | [spec doc](../specification.md) |
4242
| ✔️| Added function definition support for AsyncAPI | [spec doc](../specification.md) |
43+
| ✔️| Rename Delay state to Sleep state | [spec doc](../specification.md) |
44+
| ✔️| Added 'sleep' property to action definition | [spec doc](../specification.md) |
45+
| ✔️| Added Rate Limiting extension | [spec doc](../specification.md) |
46+
| ✔️| Update ForEach state - adding sequential exec option and batch size for parallel option | [spec doc](../specification.md) |
4347

4448
## Release Version 0.6
4549

schema/extensions/kpi.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"minLength": 1,
1919
"description": "Workflow definition unique identifier (workflow id property)"
2020
},
21+
"workflowVersions": {
22+
"type": "array",
23+
"description": "Workflow versions. If not defined, applies to all workflow instances (regardless of their associated workflow version)",
24+
"items": {
25+
"type": "string"
26+
}
27+
},
2128
"currency": {
2229
"type": "string",
2330
"default": "USD",

schema/extensions/ratelimiting.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"$id": "https://serverlessworkflow.io/schemas/0.7/extensions/ratelimiting.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"description": "Serverless Workflow specification - Various workflow rate limiting settings",
5+
"type": "object",
6+
"definitions": {
7+
"ratelimiting": {
8+
"type": "object",
9+
"description": "Serverless Workflow Rate Limiting Extension",
10+
"properties": {
11+
"extensionid": {
12+
"type": "string",
13+
"default": "workflow-ratelimiting-extension",
14+
"description": "Extension unique identifier"
15+
},
16+
"workflowid": {
17+
"type": "string",
18+
"minLength": 1,
19+
"description": "Workflow definition unique identifier (workflow id property)"
20+
},
21+
"workflowVersions": {
22+
"type": "array",
23+
"description": "Workflow versions. If not defined, applies to all workflow instances (regardless of their associated workflow version)",
24+
"items": {
25+
"type": "string"
26+
}
27+
},
28+
"singleInstance": {
29+
"description": "Rate Limit settings per single instance of a workflow with provided workflowid",
30+
"$ref": "#/definitions/ratelimits"
31+
},
32+
"allInstances": {
33+
"description": "Rate Limit settings across all instance of a workflow with provided workflowid",
34+
"$ref": "#/definitions/ratelimits"
35+
}
36+
},
37+
"required": [
38+
"extensionid",
39+
"workflowid"
40+
]
41+
},
42+
"ratelimits": {
43+
"type": "object",
44+
"properties": {
45+
"maxActionsPerSecond": {
46+
"type": "number",
47+
"default": 0,
48+
"description": "Sets the rate limiting on number of actions that can be executed per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means workflow actions can be executed once every 10 seconds. Default zero value means 'unlimited'"
49+
},
50+
"maxConcurrentActions": {
51+
"type": "number",
52+
"default": 100,
53+
"description": "Maximum number of actions that can be executed in parallel"
54+
},
55+
"maxProducedEventsPerSecond": {
56+
"type": "number",
57+
"default": 0,
58+
"description": "Sets the rate limiting on number of events that can be produced per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means workflow can produce events once every 10 seconds. Default zero value means 'unlimited'"
59+
},
60+
"maxStates": {
61+
"type": "integer",
62+
"default": 0,
63+
"description": "Maximum number of workflow states that should be executed. Default is zero, meaning unlimited."
64+
},
65+
"maxTransitions": {
66+
"type": "integer",
67+
"default": 0,
68+
"description": "Maximum number of workflow transitions that should be executed. Default is zero, meaning unlimited."
69+
}
70+
}
71+
}
72+
}
73+
}

schema/workflow.json

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@
126126
"items": {
127127
"anyOf": [
128128
{
129-
"title": "Delay State",
130-
"$ref": "#/definitions/delaystate"
129+
"title": "Sleep State",
130+
"$ref": "#/definitions/sleepstate"
131131
},
132132
{
133133
"title": "Event State",
@@ -184,6 +184,37 @@
184184
}
185185
],
186186
"definitions": {
187+
"sleep": {
188+
"type": "object",
189+
"properties": {
190+
"before": {
191+
"type": "string",
192+
"description": "Amount of time (ISO 8601 duration format) to sleep before function/subflow invocation. Does not apply if 'eventRef' is defined."
193+
},
194+
"after": {
195+
"type": "string",
196+
"description": "Amount of time (ISO 8601 duration format) to sleep after function/subflow invocation. Does not apply if 'eventRef' is defined."
197+
}
198+
},
199+
"oneOf": [
200+
{
201+
"required": [
202+
"before"
203+
]
204+
},
205+
{
206+
"required": [
207+
"after"
208+
]
209+
},
210+
{
211+
"required": [
212+
"before",
213+
"after"
214+
]
215+
}
216+
]
217+
},
187218
"crondef": {
188219
"oneOf": [
189220
{
@@ -351,6 +382,10 @@
351382
"description": "References a sub-workflow to invoke",
352383
"$ref": "#/definitions/subflowref"
353384
},
385+
"sleep": {
386+
"description": "Defines time periods workflow execution should sleep before / after function execution",
387+
"$ref": "#/definitions/sleep"
388+
},
354389
"actionDataFilter": {
355390
"description": "Action data filter",
356391
"$ref": "#/definitions/actiondatafilter"
@@ -503,9 +538,9 @@
503538
"actions"
504539
]
505540
},
506-
"delaystate": {
541+
"sleepstate": {
507542
"type": "object",
508-
"description": "Causes the workflow execution to delay for a specified duration",
543+
"description": "Causes the workflow execution to sleep for a specified duration",
509544
"properties": {
510545
"id": {
511546
"type": "string",
@@ -518,7 +553,7 @@
518553
},
519554
"type": {
520555
"type": "string",
521-
"const": "delay",
556+
"const": "sleep",
522557
"description": "State type"
523558
},
524559
"end": {
@@ -529,9 +564,9 @@
529564
"description": "State data filter",
530565
"$ref": "#/definitions/statedatafilter"
531566
},
532-
"timeDelay": {
567+
"duration": {
533568
"type": "string",
534-
"description": "Amount of time (ISO 8601 format) to delay"
569+
"description": "Duration (ISO 8601 duration format) to sleep"
535570
},
536571
"timeouts": {
537572
"type": "object",
@@ -553,7 +588,7 @@
553588
"additionalItems": false
554589
},
555590
"transition": {
556-
"description": "Next transition of the workflow after the time delay",
591+
"description": "Next transition of the workflow after the workflow sleep",
557592
"$ref": "#/definitions/transition"
558593
},
559594
"compensatedBy": {
@@ -585,7 +620,7 @@
585620
"required": [
586621
"name",
587622
"type",
588-
"timeDelay"
623+
"duration"
589624
]
590625
},
591626
"else": {
@@ -594,15 +629,15 @@
594629
"required": [
595630
"name",
596631
"type",
597-
"timeDelay",
632+
"duration",
598633
"end"
599634
]
600635
},
601636
{
602637
"required": [
603638
"name",
604639
"type",
605-
"timeDelay",
640+
"duration",
606641
"transition"
607642
]
608643
}
@@ -1412,14 +1447,14 @@
14121447
"type": "string",
14131448
"description": "Name of the iteration parameter that can be referenced in actions/workflow. For each parallel iteration, this param should contain an unique element of the inputCollection array"
14141449
},
1415-
"max": {
1450+
"batchSize": {
14161451
"type": [
14171452
"number",
14181453
"string"
14191454
],
14201455
"minimum": 0,
14211456
"minLength": 0,
1422-
"description": "Specifies how upper bound on how many iterations may run in parallel"
1457+
"description": "Specifies how many iterations may run in parallel at the same time. Used if 'mode' property is set to 'parallel' (default)"
14231458
},
14241459
"actions": {
14251460
"type": "array",
@@ -1470,6 +1505,15 @@
14701505
"default": false,
14711506
"description": "If true, this state is used to compensate another state. Default is false"
14721507
},
1508+
"mode": {
1509+
"type": "string",
1510+
"enum": [
1511+
"sequential",
1512+
"parallel"
1513+
],
1514+
"description": "Specifies how iterations are to be performed (sequentially or in parallel)",
1515+
"default": "parallel"
1516+
},
14731517
"metadata": {
14741518
"$ref": "common.json#/definitions/metadata"
14751519
}

0 commit comments

Comments
 (0)