Skip to content

Commit 6a22a45

Browse files
authored
Merge branch 'main' into feat-lifecycle-cloud-events
2 parents 8886c3a + e64b3dd commit 6a22a45

8 files changed

+174
-11
lines changed

dsl-reference.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@
7676
+ [HTTP Response](#http-response)
7777
+ [HTTP Request](#http-request)
7878
+ [URI Template](#uri-template)
79+
+ [Container Lifetime](#container-lifetime)
7980
+ [Process Result](#process-result)
8081
+ [AsyncAPI Server](#asyncapi-server)
8182
+ [AsyncAPI Message](#asyncapi-message)
8283
+ [AsyncAPI Subscription](#asyncapi-subscription)
8384
+ [Workflow Definition Reference](#workflow-definition-reference)
8485

85-
8686
## Abstract
8787

8888
This document provides comprehensive definitions and detailed property tables for all the concepts discussed in the Serverless Workflow DSL. It serves as a reference guide, explaining the structure, components, and configurations available within the DSL. By exploring this document, users will gain a thorough understanding of how to define, configure, and manage workflows, including task definitions, flow directives, and state transitions. This foundational knowledge will enable users to effectively utilize the DSL for orchestrating serverless functions and automating processes.
@@ -430,6 +430,7 @@ The [HTTP Call](#http-call) enables workflows to interact with external services
430430
| body | `any` | `no` | The HTTP request body, if any. |
431431
| query | `map[string, any]` | `no` | A name/value mapping of the query parameters to use, if any. |
432432
| output | `string` | `no` | The http call's output format.<br>*Supported values are:*<br>*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*<br>*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*<br>*- `response`, which outputs the [http response](#http-response).*<br>*Defaults to `content`.* |
433+
| redirect | `boolean` | `no` | Specifies whether redirection status codes (`300–399`) should be treated as errors.<br>*If set to `false`, runtimes must raise an error for response status codes outside the `200–299` range.*<br>*If set to `true`, they must raise an error for status codes outside the `200–399` range.*<br>*Defaults to `false`.* |
433434

434435
###### Examples
435436

@@ -460,6 +461,7 @@ The [OpenAPI Call](#openapi-call) enables workflows to interact with external se
460461
| parameters | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. |
461462
| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the OpenAPI operation. |
462463
| output | `string` | `no` | The OpenAPI call's output format.<br>*Supported values are:*<br>*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*<br>*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*<br>*- `response`, which outputs the [http response](#http-response).*<br>*Defaults to `content`.* |
464+
| redirect | `boolean` | `no` | Specifies whether redirection status codes (`300–399`) should be treated as errors.<br>*If set to `false`, runtimes must raise an error for response status codes outside the `200–299` range.*<br>*If set to `true`, they must raise an error for status codes outside the `200–399` range.*<br>*Defaults to `false`.* |
463465

464466
###### Examples
465467

@@ -629,7 +631,7 @@ Allows workflows to execute multiple subtasks concurrently, enabling parallel pr
629631
| Name | Type | Required | Description|
630632
|:--|:---:|:---:|:---|
631633
| fork.branches | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently. |
632-
| fork.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output. Defaults to `false`. |
634+
| fork.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.<br>*If set to `false`, the task returns an array that includes the outputs from each branch, preserving the order in which the branches are declared.*<br>*If to `true`, the task returns only the output of the winning branch.*<br>*Defaults to `false`.* |
633635

634636
##### Examples
635637

@@ -816,10 +818,12 @@ Enables the execution of external processes encapsulated within a containerized
816818
| Name | Type | Required | Description |
817819
|:--|:---:|:---:|:---|
818820
| image | `string` | `yes` | The name of the container image to run |
821+
| name | `string` | `no` | A [runtime expression](dsl.md#runtime-expressions), if any, used to give specific name to the container. |
819822
| command | `string` | `no` | The command, if any, to execute on the container |
820823
| ports | `map` | `no` | The container's port mappings, if any |
821824
| volumes | `map` | `no` | The container's volume mappings, if any |
822825
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process |
826+
| lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. |
823827

824828
###### Examples
825829

@@ -836,6 +840,11 @@ do:
836840
image: fake-image
837841
```
838842

843+
> [!NOTE]
844+
> When a `container process` is executed, runtime implementations are recommended to follow a predictable naming convention for the container name. This can improve monitoring, logging, and container lifecycle management.
845+
>
846+
> The Serverless Workflow specification recommends using the following convention: `{workflow.name}-{uuid}.{workflow.namespace}-{task.name}`
847+
839848
##### Script Process
840849

841850
Enables the execution of custom scripts or code within a workflow, empowering workflows to perform specialized logic, data processing, or integration tasks by executing user-defined scripts written in various programming languages.
@@ -844,12 +853,21 @@ Enables the execution of custom scripts or code within a workflow, empowering wo
844853

845854
| Name | Type | Required | Description |
846855
|:--|:---:|:---:|:---|
847-
| language | `string` | `yes` | The language of the script to run |
856+
| language | `string` | `yes` | The language of the script to run.<br>*Supported values are: [`js`](https://tc39.es/ecma262/2024/) and [`python`](https://www.python.org/downloads/release/python-3131/).* |
848857
| code | `string` | `no` | The script's code.<br>*Required if `source` has not been set.* |
849858
| source | [externalResource](#external-resource) | `no` | The script's resource.<br>*Required if `code` has not been set.* |
850859
| arguments | `map` | `no` | A list of the arguments, if any, of the script to run |
851860
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured script process |
852861

862+
> [!WARNING]
863+
> To ensure cross-compatibility, Serverless Workflow strictly limits the versions of supported scripting languages. These versions may evolve with future releases. If you wish to use a different version of a language, you may do so by utilizing the [`container process`](#container-process).
864+
865+
**Supported languages**
866+
| Language | Version |
867+
|:-----------|:---------:|
868+
| `JavaScript` | [`ES2024`](https://tc39.es/ecma262/2024/) |
869+
| `Python` | [`3.13.x`](https://www.python.org/downloads/release/python-3131/) |
870+
853871
###### Examples
854872

855873
```yaml
@@ -1512,6 +1530,9 @@ updatedAt: '2024-07-26T16:59:57-05:00'
15121530
status: completed
15131531
```
15141532

1533+
> [!WARNING]
1534+
> Flow directives may only redirect to tasks declared within their own scope. In other words, they cannot target tasks at a different depth.
1535+
15151536
### External Resource
15161537

15171538
Defines an external resource.
@@ -2320,6 +2341,16 @@ This has the following limitations compared to runtime expressions:
23202341
uri: https://petstore.swagger.io/v2/pet/{petId}
23212342
```
23222343

2344+
### Container Lifetime
2345+
2346+
Configures the lifetime of a container.
2347+
2348+
#### Properties
2349+
2350+
| Property | Type | Required | Description |
2351+
|----------|:----:|:--------:|-------------|
2352+
| cleanup | `string` | `yes` | The cleanup policy to use.<br>*Supported values are:<br>- `always`: the container is deleted immediately after execution.<br>-`never`: the runtime should never delete the container.<br>-`eventually`: the container is deleted after a configured amount of time after its execution.*<br>*Defaults to `never`.* |
2353+
| after | [`duration`](#duration) | `no` | The [`duration`](#duration), if any, after which to delete the container once executed.<br>*Required if `cleanup` has been set to `eventually`, otherwise ignored.* |
23232354
### Process Result
23242355

23252356
Describes the result of a process.
@@ -2338,13 +2369,17 @@ Describes the result of a process.
23382369
document:
23392370
dsl: '1.0.0-alpha5'
23402371
namespace: test
2341-
name: run-example
2372+
name: run-container-example
23422373
version: '0.1.0'
23432374
do:
23442375
- runContainer:
23452376
run:
23462377
container:
23472378
image: fake-image
2379+
lifetime:
2380+
cleanup: eventually
2381+
after:
2382+
minutes: 30
23482383
return: stderr
23492384
23502385
- runScript:

dsl.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ Once the task has been executed, different things can happen:
221221
- `fault`: the task raised an uncaught error, which abruptly halts the workflow's execution and makes it transition to `faulted` [status phase](#status-phases).
222222
- `end`: the task explicitly and gracefully ends the workflow's execution.
223223

224+
> [!WARNING]
225+
> Flow directives may only redirect to tasks declared within their own scope. In other words, they cannot target tasks at a different depth.
226+
224227
### Data Flow
225228

226229
In Serverless Workflow DSL, data flow management is crucial to ensure that the right data is passed between tasks and to the workflow itself.
@@ -386,6 +389,8 @@ When the evaluation of an expression fails, runtimes **must** raise an error wit
386389
| workflow | [`workflowDescriptor`](#workflow-descriptor) | Describes the current workflow. |
387390
| runtime | [`runtimeDescriptor`](#runtime-descriptor) | Describes the runtime. |
388391

392+
> [!WARNING]
393+
> Use `$secrets` with caution: incorporating them in expressions or passing them as call inputs may inadvertently expose sensitive information.
389394
390395
##### Runtime Descriptor
391396

@@ -444,6 +449,9 @@ The following table shows which arguments are available for each runtime express
444449
| Task `export.as` | Transformed task output | `$context` |||||||||
445450
| Workflow `output.as` | Last task's transformed output | Transformed workflow output || | || ||| |
446451

452+
> [!WARNING]
453+
> Use `$secrets` with caution: incorporating them in expressions or passing them as call inputs may inadvertently expose sensitive information.
454+
447455
### Fault Tolerance
448456

449457
Serverless Workflow is designed with resilience in mind, acknowledging that errors are an inevitable part of any system. The DSL provides robust mechanisms to identify, describe, and handle errors effectively, ensuring the workflow can recover gracefully from failures.

examples/call-http-redirect.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# yaml-language-server: $schema=../schema/workflow.yaml
2+
document:
3+
dsl: 1.0.0-alpha2
4+
namespace: examples
5+
name: http-query-params
6+
version: 1.0.0-alpha2
7+
input:
8+
schema:
9+
format: json
10+
document:
11+
type: object
12+
required:
13+
- searchQuery
14+
properties:
15+
searchQuery:
16+
type: string
17+
do:
18+
- searchStarWarsCharacters:
19+
call: http
20+
with:
21+
method: get
22+
endpoint: https://swapi.dev/api/people/
23+
query:
24+
search: ${.searchQuery}
25+
redirect: true
26+

examples/call-openapi-redirect.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
document:
2+
dsl: '1.0.0-alpha5'
3+
namespace: test
4+
name: openapi-example
5+
version: '0.1.0'
6+
do:
7+
- findPet:
8+
call: openapi
9+
with:
10+
document:
11+
endpoint: https://petstore.swagger.io/v2/swagger.json
12+
operationId: findPetsByStatus
13+
parameters:
14+
status: available
15+
redirect: true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
document:
2+
dsl: '1.0.0-alpha5'
3+
namespace: test
4+
name: run-container
5+
version: '0.1.0'
6+
do:
7+
- runContainer:
8+
run:
9+
container:
10+
image: hello-world
11+
lifetime:
12+
cleanup: always
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
document:
2+
dsl: '1.0.0-alpha5'
3+
namespace: test
4+
name: run-container
5+
version: '0.1.0'
6+
do:
7+
- runContainer:
8+
run:
9+
container:
10+
image: hello-world
11+
lifetime:
12+
cleanup: eventually
13+
after:
14+
minutes: 30

examples/run-container-with-name.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
document:
2+
dsl: '1.0.0-alpha5'
3+
namespace: test
4+
name: run-container-with-name
5+
version: '0.1.0'
6+
do:
7+
- runContainer:
8+
run:
9+
container:
10+
image: hello-world
11+
name: ${ "hello-\(.workflow.document.name)-\(.task.name)-\(.workflow.id)" }

schema/workflow.yaml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,29 +350,33 @@ $defs:
350350
properties:
351351
method:
352352
type: string
353-
title: WithHTTPMethod
353+
title: HTTPMethod
354354
description: The HTTP method of the HTTP request to perform.
355355
endpoint:
356-
title: WithHTTPEndpoint
356+
title: HTTPEndpoint
357357
description: The HTTP endpoint to send the request to.
358358
$ref: '#/$defs/endpoint'
359359
headers:
360360
type: object
361-
title: WithHTTPHeaders
361+
title: HTTPHeaders
362362
description: A name/value mapping of the headers, if any, of the HTTP request to perform.
363363
body:
364-
title: WithHTTPBody
364+
title: HTTPBody
365365
description: The body, if any, of the HTTP request to perform.
366366
query:
367367
type: object
368-
title: WithHTTPQuery
368+
title: HTTPQuery
369369
description: A name/value mapping of the query parameters, if any, of the HTTP request to perform.
370370
additionalProperties: true
371371
output:
372372
type: string
373-
title: WithHTTPOutput
373+
title: HTTPOutput
374374
description: The http call output format. Defaults to 'content'.
375375
enum: [ raw, content, response ]
376+
redirect:
377+
type: boolean
378+
title: HttpRedirect
379+
description: Specifies whether redirection status codes (`300–399`) should be treated as errors.
376380
required: [ method, endpoint ]
377381
unevaluatedProperties: false
378382
- title: CallOpenAPI
@@ -412,6 +416,10 @@ $defs:
412416
enum: [ raw, content, response ]
413417
title: WithOpenAPIOutput
414418
description: The http call output format. Defaults to 'content'.
419+
redirect:
420+
type: boolean
421+
title: HttpRedirect
422+
description: Specifies whether redirection status codes (`300–399`) should be treated as errors.
415423
required: [ document, operationId ]
416424
unevaluatedProperties: false
417425
- title: CallFunction
@@ -614,6 +622,10 @@ $defs:
614622
type: string
615623
title: ContainerImage
616624
description: The name of the container image to run.
625+
name:
626+
type: string
627+
title: ContainerName
628+
description: A runtime expression, if any, used to give specific name to the container.
617629
command:
618630
type: string
619631
title: ContainerCommand
@@ -630,6 +642,10 @@ $defs:
630642
type: object
631643
title: ContainerEnvironment
632644
description: A key/value mapping of the environment variables, if any, to use when running the configured process.
645+
lifetime:
646+
$ref: '#/$defs/containerLifetime'
647+
title: ContainerLifetime
648+
description: An object, if any, used to configure the container's lifetime
633649
required: [ image ]
634650
required: [ container ]
635651
- title: RunScript
@@ -1554,6 +1570,32 @@ $defs:
15541570
title: RuntimeExpression
15551571
description: A runtime expression.
15561572
pattern: "^\\s*\\$\\{.+\\}\\s*$"
1573+
containerLifetime:
1574+
type: object
1575+
title: ContainerLifetime
1576+
description: The configuration of a container's lifetime
1577+
unevaluatedProperties: false
1578+
properties:
1579+
cleanup:
1580+
type: string
1581+
title: ContainerCleanupPolicy
1582+
description: The container cleanup policy to use
1583+
enum: [ always, never, eventually ]
1584+
default: never
1585+
after:
1586+
$ref: '#/$defs/duration'
1587+
title: ContainerLifetimeDuration
1588+
description: The duration after which to cleanup the container, in case the cleanup policy has been set to 'eventually'
1589+
required: [ cleanup ]
1590+
if:
1591+
properties:
1592+
cleanup:
1593+
const: eventually
1594+
then:
1595+
required: [ after ]
1596+
else:
1597+
not:
1598+
required: [ after ]
15571599
processResult:
15581600
type: object
15591601
title: ProcessResult
@@ -1658,4 +1700,4 @@ $defs:
16581700
$ref: '#/$defs/runtimeExpression'
16591701
title: AsyncApiMessageConsumptionPolicyUntil
16601702
description: A runtime expression evaluated before each consumed (filtered) message to decide if message consumption should continue.
1661-
required: [ until ]
1703+
required: [ until ]

0 commit comments

Comments
 (0)