Skip to content

Commit fbcd135

Browse files
authored
Merge pull request #1002 from neuroglia-io/fix-component-references
Added new reusable components and fixed unreferenceable errors and retries
2 parents 72813e8 + 454eb2b commit fbcd135

File tree

6 files changed

+89
-20
lines changed

6 files changed

+89
-20
lines changed

dsl-reference.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t
7373
| input | [`input`](#input) | `no` | Configures the workflow's input. |
7474
| use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. |
7575
| do | [`map[string, task][]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). |
76-
| timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. |
76+
| timeout | `string`<br>[`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout.<br>*If a `string`, must be the name of a [timeout](#timeout) defined in the [workflow's reusable components](#use).* |
7777
| output | [`output`](#output) | `no` | Configures the workflow's output. |
7878
| schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. |
7979
| evaluate | [`evaluate`](#evaluate) | `no` | Configures runtime expression evaluation. |
@@ -105,6 +105,7 @@ Defines the workflow's reusable components.
105105
| functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. |
106106
| retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. |
107107
| secrets | `string[]` | `no` | A list containing the workflow's secrets. |
108+
| timeouts | [`map[string, timeout]`](#timeout) | `no` | A name/value mapping of the workflow's reusable timeouts. |
108109

109110
#### Schedule
110111

@@ -252,7 +253,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
252253
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
253254
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
254255
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
255-
| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. |
256+
| timeout | `string`<br>[`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any.<br>*If a `string`, must be the name of a [timeout](#timeout) defined in the [workflow's reusable components](#use).* |
256257
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
257258
| metadata | `map` | `no` | Additional information about the task. |
258259

@@ -653,7 +654,7 @@ Intentionally triggers and propagates errors. By employing the "Raise" task, wor
653654

654655
| Name | Type | Required | Description |
655656
|:--|:---:|:---:|:---|
656-
| raise.error | [`error`](#error) | `yes` | Defines the error to raise. |
657+
| raise.error | `string`<br>[`error`](#error) | `yes` | Defines the [error](#error) to raise.<br>*If a `string`, must be the name of an [error](#error) defined in the [workflow's reusable components](#use).* |
657658

658659
##### Examples
659660

@@ -1035,12 +1036,12 @@ Defines the configuration of a catch clause, which a concept used to catch error
10351036

10361037
| Name | Type | Required | Description |
10371038
|:--|:---:|:---:|:---|
1038-
| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch |
1039+
| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch. |
10391040
| as | `string` | `no` | The name of the runtime expression variable to save the error as. Defaults to 'error'. |
1040-
| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error |
1041-
| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error |
1042-
| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors |
1043-
| do | [`map[string, task][]`](#task) | `no` | The definition of the task(s) to run when catching an error |
1041+
| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error. |
1042+
| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error. |
1043+
| retry | `string`<br>[`retryPolicy`](#retry) | `no` | The [`retry policy`](#retry) to use, if any, when catching [`errors`](#error).<br>*If a `string`, must be the name of a [retry policy](#retry) defined in the [workflow's reusable components](#use).* |
1044+
| do | [`map[string, task][]`](#task) | `no` | The definition of the task(s) to run when catching an error. |
10441045

10451046
#### Wait
10461047

File renamed without changes.

examples/raise-reusable.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
document:
2+
dsl: '1.0.0-alpha1'
3+
namespace: test
4+
name: raise-not-implemented
5+
version: '0.1.0'
6+
use:
7+
errors:
8+
notImplemented:
9+
type: https://serverlessworkflow.io/errors/not-implemented
10+
status: 500
11+
title: Not Implemented
12+
detail: ${ "The workflow '\( $workflow.definition.document.name ):\( $workflow.definition.document.version )' is a work in progress and cannot be run yet" }
13+
do:
14+
- notImplemented:
15+
raise:
16+
error: notImplemented
File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
document:
2+
dsl: '1.0.0'
3+
namespace: default
4+
name: try-catch-retry
5+
version: '1.0.0'
6+
use:
7+
retries:
8+
default:
9+
delay:
10+
seconds: 3
11+
backoff:
12+
exponential: {}
13+
limit:
14+
attempt:
15+
count: 5
16+
do:
17+
- tryGetPet:
18+
try:
19+
- getPet:
20+
call: http
21+
with:
22+
method: get
23+
endpoint: https://petstore.swagger.io/v2/pet/{petId}
24+
catch:
25+
errors:
26+
with:
27+
type: https://serverlessworkflow.io.io/dsl/errors/types/communication
28+
status: 503
29+
retry: default
30+

schema/workflow.yaml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,24 @@ properties:
101101
items:
102102
type: string
103103
description: The workflow's secrets.
104+
timeouts:
105+
type: object
106+
title: UseTimeouts
107+
description: The workflow's reusable timeouts.
108+
additionalProperties:
109+
$ref: '#/$defs/timeout'
104110
do:
105111
$ref: '#/$defs/taskList'
106112
title: Do
107113
description: Defines the task(s) the workflow must perform.
108114
timeout:
109-
$ref: '#/$defs/timeout'
110-
title: Timeout
111-
description: The workflow's timeout configuration, if any.
115+
oneOf:
116+
- $ref: '#/$defs/timeout'
117+
title: TimeoutDefinition
118+
description: The workflow's timeout configuration, if any.
119+
- type: string
120+
title: TimeoutReference
121+
description: The name of the workflow's timeout, if any.
112122
output:
113123
$ref: '#/$defs/output'
114124
title: Output
@@ -169,9 +179,13 @@ $defs:
169179
title: TaskBaseExport
170180
description: Export task output to context.
171181
timeout:
172-
$ref: '#/$defs/timeout'
173-
title: TaskBaseTimeout
174-
description: The task's timeout configuration, if any.
182+
oneOf:
183+
- $ref: '#/$defs/timeout'
184+
title: TaskTimeoutDefinition
185+
description: The task's timeout configuration, if any.
186+
- type: string
187+
title: TaskTimeoutReference
188+
description: The name of the task's timeout, if any.
175189
then:
176190
$ref: '#/$defs/flowDirective'
177191
title: TaskBaseThen
@@ -531,9 +545,13 @@ $defs:
531545
unevaluatedProperties: false
532546
properties:
533547
error:
534-
$ref: '#/$defs/error'
535-
title: RaiseError
536-
description: Defines the error to raise.
548+
oneOf:
549+
- $ref: '#/$defs/error'
550+
title: RaiseErrorDefinition
551+
description: Defines the error to raise.
552+
- type: string
553+
title: RaiseErrorReference
554+
description: The name of the error to raise
537555
required: [ error ]
538556
runTask:
539557
type: object
@@ -757,9 +775,13 @@ $defs:
757775
title: CatchExceptWhen
758776
description: A runtime expression used to determine whether or not to catch the filtered error.
759777
retry:
760-
$ref: '#/$defs/retryPolicy'
761-
title: TryTaskCatchRetry
762-
description: The retry policy to use, if any, when catching errors.
778+
oneOf:
779+
- $ref: '#/$defs/retryPolicy'
780+
title: RetryPolicyDefinition
781+
description: The retry policy to use, if any, when catching errors.
782+
- type: string
783+
title: RetryPolicyReference
784+
description: The name of the retry policy to use, if any, when catching errors.
763785
do:
764786
$ref: '#/$defs/taskList'
765787
title: TryTaskCatchDo

0 commit comments

Comments
 (0)