Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new reusable components and fixed unreferenceable errors and retries #1002

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t
| input | [`input`](#input) | `no` | Configures the workflow's input. |
| use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. |
| do | [`map[string, task][]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). |
| timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. |
| 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).* |
| output | [`output`](#output) | `no` | Configures the workflow's output. |
| schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. |
| evaluate | [`evaluate`](#evaluate) | `no` | Configures runtime expression evaluation. |
Expand Down Expand Up @@ -105,6 +105,7 @@ Defines the workflow's reusable components.
| functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. |
| retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. |
| secrets | `string[]` | `no` | A list containing the workflow's secrets. |
| timeouts | [`map[string, timeout]`](#timeout) | `no` | A name/value mapping of the workflow's reusable timeouts. |

#### Schedule

Expand Down Expand Up @@ -252,7 +253,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. |
| 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).* |
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
| metadata | `map` | `no` | Additional information about the task. |

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

| Name | Type | Required | Description |
|:--|:---:|:---:|:---|
| raise.error | [`error`](#error) | `yes` | Defines the error to raise. |
| 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).* |

##### Examples

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

| Name | Type | Required | Description |
|:--|:---:|:---:|:---|
| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch |
| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch. |
| as | `string` | `no` | The name of the runtime expression variable to save the error as. Defaults to 'error'. |
| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error |
| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error |
| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors |
| do | [`map[string, task][]`](#task) | `no` | The definition of the task(s) to run when catching an error |
| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error. |
| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error. |
| 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).* |
| do | [`map[string, task][]`](#task) | `no` | The definition of the task(s) to run when catching an error. |

#### Wait

Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions examples/raise-reusable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
document:
dsl: '1.0.0-alpha1'
namespace: test
name: raise-not-implemented
version: '0.1.0'
use:
errors:
notImplemented:
type: https://serverlessworkflow.io/errors/not-implemented
status: 500
title: Not Implemented
detail: ${ "The workflow '\( $workflow.definition.document.name ):\( $workflow.definition.document.version )' is a work in progress and cannot be run yet" }
do:
- notImplemented:
raise:
error: notImplemented
File renamed without changes.
30 changes: 30 additions & 0 deletions examples/try-catch-retry-reusable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
document:
dsl: '1.0.0'
namespace: default
name: try-catch-retry
version: '1.0.0'
use:
retries:
default:
delay:
seconds: 3
backoff:
exponential: {}
limit:
attempt:
count: 5
do:
- tryGetPet:
try:
- getPet:
call: http
with:
method: get
endpoint: https://petstore.swagger.io/v2/pet/{petId}
catch:
errors:
with:
type: https://serverlessworkflow.io.io/dsl/errors/types/communication
status: 503
retry: default

46 changes: 34 additions & 12 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,24 @@ properties:
items:
type: string
description: The workflow's secrets.
timeouts:
type: object
title: UseTimeouts
description: The workflow's reusable timeouts.
additionalProperties:
$ref: '#/$defs/timeout'
do:
$ref: '#/$defs/taskList'
title: Do
description: Defines the task(s) the workflow must perform.
timeout:
$ref: '#/$defs/timeout'
title: Timeout
description: The workflow's timeout configuration, if any.
oneOf:
- $ref: '#/$defs/timeout'
title: TimeoutDefinition
description: The workflow's timeout configuration, if any.
- type: string
title: TimeoutReference
description: The name of the workflow's timeout, if any.
output:
$ref: '#/$defs/output'
title: Output
Expand Down Expand Up @@ -169,9 +179,13 @@ $defs:
title: TaskBaseExport
description: Export task output to context.
timeout:
$ref: '#/$defs/timeout'
title: TaskBaseTimeout
description: The task's timeout configuration, if any.
oneOf:
- $ref: '#/$defs/timeout'
title: TaskTimeoutDefinition
description: The task's timeout configuration, if any.
- type: string
title: TaskTimeoutReference
description: The name of the task's timeout, if any.
then:
$ref: '#/$defs/flowDirective'
title: TaskBaseThen
Expand Down Expand Up @@ -531,9 +545,13 @@ $defs:
unevaluatedProperties: false
properties:
error:
$ref: '#/$defs/error'
title: RaiseError
description: Defines the error to raise.
oneOf:
- $ref: '#/$defs/error'
title: RaiseErrorDefinition
description: Defines the error to raise.
- type: string
title: RaiseErrorReference
description: The name of the error to raise
required: [ error ]
runTask:
type: object
Expand Down Expand Up @@ -757,9 +775,13 @@ $defs:
title: CatchExceptWhen
description: A runtime expression used to determine whether or not to catch the filtered error.
retry:
$ref: '#/$defs/retryPolicy'
title: TryTaskCatchRetry
description: The retry policy to use, if any, when catching errors.
oneOf:
- $ref: '#/$defs/retryPolicy'
title: RetryPolicyDefinition
description: The retry policy to use, if any, when catching errors.
- type: string
title: RetryPolicyReference
description: The name of the retry policy to use, if any, when catching errors.
do:
$ref: '#/$defs/taskList'
title: TryTaskCatchDo
Expand Down
Loading