Skip to content

Commit 8a457a2

Browse files
Merge branch 'main' into matthias-pichler/define-a-priority-906
2 parents 5a705ca + fbd77b0 commit 8a457a2

File tree

6 files changed

+231
-106
lines changed

6 files changed

+231
-106
lines changed

ctk/features/set.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Feature: Set Task
33
I want to ensure that set tasks can be executed within the workflow
44
So that my implementation conforms to the expected behavior
55

6-
# Tests emit tasks
6+
# Tests set tasks
77
Scenario: Set Task
88
Given a workflow with definition:
99
"""yaml

dsl-reference.md

Lines changed: 96 additions & 39 deletions
Large diffs are not rendered by default.

dsl.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Workflows in the Serverless Workflow DSL can exist in several phases, each indic
9999

100100
Additionally, the flow of execution within a workflow can be controlled using [directives*](dsl-reference.md#flow-directive), which provide instructions to the workflow engine on how to manage and handle specific aspects of workflow execution.
101101

102-
**To learn more about flow directives and how they can be utilized to control the execution and behavior of workflows, please refer to [Flow Directives](dsl-reference.md#flow-directive).*
102+
\**To learn more about flow directives and how they can be utilized to control the execution and behavior of workflows, please refer to [Flow Directives](dsl-reference.md#flow-directive).*
103103

104104
#### Components
105105

@@ -120,14 +120,14 @@ The Serverless Workflow DSL defines several default [task](dsl-reference.md#task
120120

121121
- [Call](dsl-reference.md#call), used to call services and/or functions.
122122
- [Do](dsl-reference.md#do), used to define one or more subtasks to perform in sequence.
123-
- [Fork](dsl-reference.md#fork), used to define one or more two subtasks to perform in parallel.
124123
- [Emit](dsl-reference.md#emit), used to emit [events](dsl-reference.md#event).
125124
- [For](dsl-reference.md#for), used to iterate over a collection of items, and conditionally perform a task for each of them.
125+
- [Fork](dsl-reference.md#fork), used to define one or more two subtasks to perform in parallel.
126126
- [Listen](dsl-reference.md#listen), used to listen for an [event](dsl-reference.md#event) or more.
127127
- [Raise](dsl-reference.md#raise), used to raise an [error](dsl-reference.md#error) and potentially fault the [workflow](dsl-reference.md#workflow).
128128
- [Run](dsl-reference.md#run), used to run a [container](dsl-reference.md#container-process), a [script](dsl-reference.md#script-process), a [shell](dsl-reference.md#shell-process) command or even another [workflow](dsl-reference.md#workflow-process).
129-
- [Switch](dsl-reference.md#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions
130129
- [Set](dsl-reference.md#set), used to dynamically set or update the [workflow](dsl-reference.md#workflow)'s data during the its execution.
130+
- [Switch](dsl-reference.md#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions
131131
- [Try](dsl-reference.md#try), used to attempt executing a specified [task](dsl-reference.md#task), and to handle any resulting [errors](dsl-reference.md#error) gracefully, allowing the [workflow](dsl-reference.md#workflow) to continue without interruption.
132132
- [Wait](dsl-reference.md#wait), used to pause or wait for a specified duration before proceeding to the next task.
133133

@@ -156,7 +156,7 @@ A workflow begins with the first task defined.
156156

157157
Once the task has been executed, different things can happen:
158158

159-
- `continue`: the task ran to completion, and the next task, if any, should be executed. The task to run next is implictly the next in declaration order, or explicitly defined by the `then` property of the executed task. If the executed task is the last task, then the workflow's execution gracefully ends.
159+
- `continue`: the task ran to completion, and the next task, if any, should be executed. The task to run next is implicitly the next in declaration order, or explicitly defined by the `then` property of the executed task. If the executed task is the last task, then the workflow's execution gracefully ends.
160160
- `fault`: the task raised an uncaught error, which abruptly halts the workflow's execution and makes it transition to `faulted` [status phase](#status-phases).
161161
- `end`: the task explicitly and gracefully ends the workflow's execution.
162162

@@ -214,17 +214,50 @@ Runtimes **may** optionally support other runtime expression languages, which au
214214

215215
CloudFlows defines [several arguments](#runtime-expression-arguments) that runtimes **must** provide during the evaluation of runtime expressions.
216216

217-
When the evaluation of an expression fails, runtimes **must** raise an error with type `https://https://serverlessworkflow.io/spec/1.0.0/errors/expression` and status `400`.
217+
When the evaluation of an expression fails, runtimes **must** raise an error with type `https://serverlessworkflow.io/spec/1.0.0/errors/expression` and status `400`.
218218

219219
#### Runtime expression arguments
220220

221221
| Name | Type | Description |
222222
|:-----|:----:|:------------|
223-
| context | `map` | The task's context data. |
223+
| context | `any` | The task's context data. |
224224
| input | `any` | The task's filtered input. |
225225
| secrets | `map` | A key/value map of the workflow secrets.<br>To avoid unintentional bleeding, secrets can only be used in the `input.from` runtime expression. |
226226
| task | [`taskDescriptor`](#task-descriptor) | Describes the current task. |
227-
| workflow | [`workflowDescritor`](#workflow-descriptor) | Describes the current workflow. |
227+
| workflow | [`workflowDescriptor`](#workflow-descriptor) | Describes the current workflow. |
228+
| runtime | [`runtimeDescriptor`](#runtime-descriptor) | Describes the runtime. |
229+
230+
##### Runtime Descriptor
231+
232+
This argument contains information about the runtime executing the workflow.
233+
234+
| Name | Type | Description | Example |
235+
|:-----|:----:|:------------| ------- |
236+
| name | `string` | A human friendly name for the runtime. | `Synapse`, `Sonata` |
237+
| version | `string` | The version of the runtime. This can be an arbitrary string | a incrementing positive integer (`362`), semantic version (`1.4.78`), commit hash (`04cd3be6da98fc35422c8caa821e0aa1ef6b2c02`) or container image label (`v0.7.43-alpine`) |
238+
| metadata | `map` | An object/map of implementation specific key-value pairs. This can be chosen by runtime implementors and usage of this argument signals that a given workflow definition might not be runtime agnostic | A Software as a Service (SaaS) provider might choose to expose information about the tenant the workflow is executed for e.g. `{ "organization": { "id": "org-ff51cff2-fc83-4d70-9af1-8dacdbbce0be", "name": "example-corp" }, "featureFlags": ["fastZip", "arm64"] }`. |
239+
240+
##### Task Descriptor
241+
242+
| Name | Type | Description | Example |
243+
|:-----|:----:|:------------|:--------|
244+
| name | `string` | The task's name. | `getPet` |
245+
| definition | `map` | The tasks definition (specified under the name) as a parsed object | `{ "call": "http", "with": { ... } }` |
246+
| input | `any` | The task's input *BEFORE* the `input.from` expression. For the result of `input.from` expression use the context of the runtime expression (for jq `.`) | - |
247+
| startedAt.iso8601 | `string` | The start time of the task as a ISO 8601 date time string. It uses `T` as the date-time delimiter, either UTC (`Z`) or a time zone offset (`+01:00`). The precision can be either seconds, milliseconds or nanoseconds | `2022-01-01T12:00:00Z`, `2022-01-01T12:00:00.123456Z`, `2022-01-01T12:00:00.123+01:00` |
248+
| startedAt.epochMillis | `integer` | The start time of the task as a integer value of milliseconds since midnight of 1970-01-01 UTC | `1641024000123` (="2022-01-01T08:00:00.123Z") |
249+
| startedAt.epochNanos | `integer` | The start time of the task as a integer value of nanoseconds since midnight of 1970-01-01 UTC | `1641024000123456` (="2022-01-01T08:00:00.123456Z") |
250+
251+
##### Workflow Descriptor
252+
253+
| Name | Type | Description | Example |
254+
|:-----|:----:|:------------|:--------|
255+
| id | `string` | A unique id of the workflow execution. Now specific format is imposed | UUIDv4: `4a5c8422-5868-4e12-8dd9-220810d2b9ee`, ULID: `0000004JFGDSW1H037G7J7SFB9` |
256+
| definition | `map` | The workflow's definition as a parsed object | `{ "document": { ... }, "do": [...] }` |
257+
| input | `any` | The workflow's input *BEFORE* the `input.from` expression. For the result of `input.from` expression use the `$input` argument | - |
258+
| startedAt.iso8601 | `string` | The start time of the execution as a ISO 8601 date time string. It uses `T` as the date-time delimiter, either UTC (`Z`) or a time zone offset (`+01:00`). The precision can be either seconds, milliseconds or nanoseconds | `2022-01-01T12:00:00Z`, `2022-01-01T12:00:00.123456Z`, `2022-01-01T12:00:00.123+01:00` |
259+
| startedAt.epochMillis | `integer` | The start time of the execution as a integer value of milliseconds since midnight of 1970-01-01 UTC | `1641024000123` (="2022-01-01T08:00:00.123Z") |
260+
| startedAt.epochNanos | `integer` | The start time of the execution as a integer value of nanoseconds since midnight of 1970-01-01 UTC | `1641024000123456` (="2022-01-01T08:00:00.123456Z") |
228261

229262
### Fault Tolerance
230263

@@ -238,7 +271,7 @@ Errors in Serverless Workflow are described using the [Problem Details RFC](http
238271

239272
*Example error:*
240273
```yaml
241-
type: https://https://serverlessworkflow.io/spec/1.0.0/errors/communication
274+
type: https://serverlessworkflow.io/spec/1.0.0/errors/communication
242275
title: Service Unavailable
243276
status: 503
244277
detail: The service is currently unavailable. Please try again later.
@@ -281,7 +314,7 @@ Workflows and tasks alike can be configured to timeout after a defined amount of
281314

282315
When a timeout occur, runtimes **must** abruptly interrupt the execution of the workflow/task, and **must** raise an error that, if uncaught, force the workflow/task to transition to the [`faulted` status phase](#status-phases).
283316

284-
A timeout error **must** have its `type` set to `https://https://serverlessworkflow.io/spec/1.0.0/errors/timeout` and **should** have its `status` set to `408`.
317+
A timeout error **must** have its `type` set to `https://serverlessworkflow.io/spec/1.0.0/errors/timeout` and **should** have its `status` set to `408`.
285318

286319
### Interoperability
287320

@@ -293,7 +326,7 @@ Serverless Workflow DSL is designed to seamlessly interact with a variety of ser
293326
- [**AsyncAPI**](dsl-reference.md#asyncapi-call): Facilitates interaction with asynchronous messaging protocols. AsyncAPI is designed for event-driven architectures, allowing workflows to publish and subscribe to events.
294327
- [**OpenAPI**](dsl-reference.md#openapi-call): Enables communication with services that provide OpenAPI specifications, which is useful for defining and consuming RESTful APIs.
295328

296-
Runtimes **must** raise an error with type `https://https://serverlessworkflow.io/spec/1.0.0/errors/communication` if and when a problem occurs during a call.
329+
Runtimes **must** raise an error with type `https://serverlessworkflow.io/spec/1.0.0/errors/communication` if and when a problem occurs during a call.
297330

298331
#### Custom and Non-Standard Interactions
299332

examples/http-query-params.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# yaml-language-server: $schema=https://serverlessworkflow.io/schemas/1.0.0-alpha2/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+
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-alpha1
3+
namespace: samples
4+
name: run-script-with-arguments
5+
version: 0.1.0
6+
do:
7+
- log:
8+
run:
9+
script:
10+
language: javascript
11+
arguments:
12+
message: ${ .message }
13+
code: >
14+
console.log(message)

schema/workflow.yaml

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
$id: https://serverlessworkflow.io/schemas/1.0.0-alpha1/workflow.yaml
23
$schema: https://json-schema.org/draft/2020-12/schema
34
description: Serverless Workflow DSL - Workflow Schema
@@ -266,6 +267,10 @@ $defs:
266267
description: A name/value mapping of the headers, if any, of the HTTP request to perform.
267268
body:
268269
description: The body, if any, of the HTTP request to perform.
270+
query:
271+
type: object
272+
additionalProperties: true
273+
description: A name/value mapping of the query parameters, if any, of the HTTP request to perform.
269274
output:
270275
type: string
271276
enum: [ raw, content, response ]
@@ -365,37 +370,9 @@ $defs:
365370
event:
366371
type: object
367372
properties:
368-
id:
369-
type: string
370-
description: The event's unique identifier
371-
source:
372-
description: Identifies the context in which an event happened
373-
oneOf:
374-
- title: LiteralSource
375-
type: string
376-
format: uri-template
377-
- $ref: '#/$defs/runtimeExpression'
378-
type:
379-
type: string
380-
description: This attribute contains a value describing the type of event related to the originating occurrence.
381-
time:
382-
oneOf:
383-
- title: LiteralTime
384-
type: string
385-
format: date-time
386-
- $ref: '#/$defs/runtimeExpression'
387-
subject:
388-
type: string
389-
datacontenttype:
390-
type: string
391-
description: Content type of data value. This attribute enables data to carry any type of content, whereby format and encoding might differ from that of the chosen event format.
392-
dataschema:
393-
oneOf:
394-
- title: LiteralDataSchema
395-
type: string
396-
format: uri-template
397-
- $ref: '#/$defs/runtimeExpression'
398-
required: [ source, type ]
373+
with:
374+
$ref: '#/$defs/eventProperties'
375+
required: [ source, type ]
399376
additionalProperties: true
400377
required: [ event ]
401378
forTask:
@@ -504,11 +481,16 @@ $defs:
504481
language:
505482
type: string
506483
description: The language of the script to run.
484+
arguments:
485+
title: ScriptArguments
486+
type: object
487+
additionalProperties: true
488+
description: A key/value mapping of the arguments, if any, to use when running the configured script.
507489
environment:
508490
title: ScriptEnvironment
509491
type: object
510492
additionalProperties: true
511-
description: A key/value mapping of the environment variables, if any, to use when running the configured process.
493+
description: A key/value mapping of the environment variables, if any, to use when running the configured script process.
512494
oneOf:
513495
- title: ScriptInline
514496
properties:
@@ -730,7 +712,7 @@ $defs:
730712
properties:
731713
authority:
732714
type: string
733-
format: uri
715+
format: uri-template
734716
description: The URI that references the OAuth2 authority to use.
735717
grant:
736718
type: string
@@ -848,6 +830,40 @@ $defs:
848830
$ref: '#/$defs/referenceableAuthenticationPolicy'
849831
description: The authentication policy to use.
850832
required: [ uri ]
833+
eventProperties:
834+
type: object
835+
properties:
836+
id:
837+
type: string
838+
description: The event's unique identifier
839+
source:
840+
description: Identifies the context in which an event happened
841+
oneOf:
842+
- title: LiteralSource
843+
type: string
844+
format: uri-template
845+
- $ref: '#/$defs/runtimeExpression'
846+
type:
847+
type: string
848+
description: This attribute contains a value describing the type of event related to the originating occurrence.
849+
time:
850+
oneOf:
851+
- title: LiteralTime
852+
type: string
853+
format: date-time
854+
- $ref: '#/$defs/runtimeExpression'
855+
subject:
856+
type: string
857+
datacontenttype:
858+
type: string
859+
description: Content type of data value. This attribute enables data to carry any type of content, whereby format and encoding might differ from that of the chosen event format.
860+
dataschema:
861+
oneOf:
862+
- title: LiteralDataSchema
863+
type: string
864+
format: uri-template
865+
- $ref: '#/$defs/runtimeExpression'
866+
additionalProperties: true
851867
eventConsumptionStrategy:
852868
type: object
853869
unevaluatedProperties: false
@@ -880,28 +896,8 @@ $defs:
880896
properties:
881897
with:
882898
title: WithEvent
883-
type: object
899+
$ref: '#/$defs/eventProperties'
884900
minProperties: 1
885-
properties:
886-
id:
887-
type: string
888-
description: The event's unique identifier
889-
source:
890-
type: string
891-
description: Identifies the context in which an event happened
892-
type:
893-
type: string
894-
description: This attribute contains a value describing the type of event related to the originating occurrence.
895-
time:
896-
type: string
897-
subject:
898-
type: string
899-
datacontenttype:
900-
type: string
901-
description: Content type of data value. This attribute enables data to carry any type of content, whereby format and encoding might differ from that of the chosen event format.
902-
dataschema:
903-
type: string
904-
additionalProperties: true
905901
description: An event filter is a mechanism used to selectively process or handle events based on predefined criteria, such as event type, source, or specific attributes.
906902
correlate:
907903
type: object
@@ -940,14 +936,14 @@ $defs:
940936
externalResource:
941937
oneOf:
942938
- type: string
943-
format: uri
939+
format: uri-template
944940
- title: ExternalResourceURI
945941
type: object
946942
unevaluatedProperties: false
947943
properties:
948944
uri:
949945
type: string
950-
format: uri
946+
format: uri-template
951947
description: The endpoint's URI.
952948
authentication:
953949
$ref: '#/$defs/referenceableAuthenticationPolicy'

0 commit comments

Comments
 (0)