Skip to content

Commit a9ce22d

Browse files
authored
Merge branch 'main' into feat-script-arguments
2 parents 0702aef + 4e03cdb commit a9ce22d

File tree

4 files changed

+99
-77
lines changed

4 files changed

+99
-77
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: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
+ [Shell](#shell-process)
2626
+ [Script](#script-process)
2727
+ [Workflow](#workflow-process)
28-
- [Switch](#switch)
2928
- [Set](#set)
29+
- [Switch](#switch)
3030
- [Try](#try)
3131
- [Wait](#wait)
3232
+ [Flow Directive](#flow-directive)
@@ -42,6 +42,7 @@
4242
- [Standard Error Types](#standard-error-types)
4343
+ [Event Consumption Strategy](#event-consumption-strategy)
4444
+ [Event Filter](#event-filter)
45+
+ [Event Properties](#event-properties)
4546
+ [Retry](#retry)
4647
+ [Input](#input)
4748
+ [Output](#output)
@@ -230,9 +231,9 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
230231
- [Call](#call), used to call services and/or functions.
231232
- [Do](#do), used to define one or more subtasks to perform in sequence.
232233
- [Fork](#fork), used to define one or more subtasks to perform concurrently.
233-
- [Emit](#emit), used to emit [events](#event).
234+
- [Emit](#emit), used to emit [events](#event-properties).
234235
- [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them.
235-
- [Listen](#listen), used to listen for an [event](#event) or more.
236+
- [Listen](#listen), used to listen for an [event](#event-properties) or more.
236237
- [Raise](#raise), used to raise an [error](#error) and potentially fault the [workflow](#workflow).
237238
- [Run](#run), used to run a [container](#container-process), a [script](#script-process) , a [shell](#shell-process) command or even another [workflow](#workflow-process).
238239
- [Switch](#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions
@@ -369,7 +370,7 @@ The [HTTP Call](#http-call) enables workflows to interact with external services
369370
| Name | Type | Required | Description|
370371
|:--|:---:|:---:|:---|
371372
| method | `string` | `yes` | The HTTP request method. |
372-
| endpoint | [`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. |
373+
| endpoint | `string`\|[`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. |
373374
| headers | `map` | `no` | A name/value mapping of the HTTP headers to use, if any. |
374375
| body | `any` | `no` | The HTTP request body, if any. |
375376
| query | `map[string, any]` | `no` | A name/value mapping of the query parameters to use, if any. |
@@ -496,7 +497,7 @@ Allows workflows to publish events to event brokers or messaging systems, facili
496497

497498
| Name | Type | Required | Description |
498499
|:--|:---:|:---:|:---|
499-
| emit.event | [`event`](#event) | `yes` | Defines the event to emit. |
500+
| emit.event | [`eventProperties`](#event-properties) | `yes` | Defines the event to emit. |
500501

501502
##### Examples
502503

@@ -510,15 +511,16 @@ do:
510511
- emitEvent:
511512
emit:
512513
event:
513-
source: https://petstore.com
514-
type: com.petstore.order.placed.v1
515-
data:
516-
client:
517-
firstName: Cruella
518-
lastName: de Vil
519-
items:
520-
- breed: dalmatian
521-
quantity: 101
514+
with:
515+
source: https://petstore.com
516+
type: com.petstore.order.placed.v1
517+
data:
518+
client:
519+
firstName: Cruella
520+
lastName: de Vil
521+
items:
522+
- breed: dalmatian
523+
quantity: 101
522524
```
523525

524526
#### For
@@ -530,9 +532,9 @@ Allows workflows to iterate over a collection of items, executing a defined set
530532
| Name | Type | Required | Description|
531533
|:--|:---:|:---:|:---|
532534
| for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.<br>Defaults to `item`. |
533-
| for.in | `string` | `yes` | A [runtime expression](./dsl.md/#runtime-expressions) used to get the collection to enumerate. |
535+
| for.in | `string` | `yes` | A [runtime expression](dsl.md#runtime-expressions) used to get the collection to enumerate. |
534536
| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.<br>Defaults to `index`. |
535-
| while | `string` | `no` | A [runtime expression](./dsl.md/#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. |
537+
| while | `string` | `no` | A [runtime expression](dsl.md#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. |
536538
| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. |
537539

538540
##### Examples
@@ -968,7 +970,7 @@ do:
968970

969971
##### Switch Case
970972

971-
Defines a switch case, encompassing of a condition for matching and an associated action to execute upon a match.
973+
Defines a switch case, encompassing a condition for matching and an associated action to execute upon a match.
972974

973975
| Name | Type | Required | Description |
974976
|:--|:---:|:---:|:---|
@@ -1393,6 +1395,28 @@ Represents the configuration of an event consumption strategy.
13931395
| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.<br>*Required if `all` and `one` have not been set.* |
13941396
| one | [`eventFilter`](#event-filter) | `no` | Configures the workflow to wait for the defined event before resuming execution.<br>*Required if `all` and `any` have not been set.* |
13951397

1398+
### Event Properties
1399+
1400+
An event object typically includes details such as the event type, source, timestamp, and unique identifier along with any relevant data payload. The [Cloud Events specification](https://cloudevents.io/), favored by Serverless Workflow, standardizes this structure to ensure interoperability across different systems and services.
1401+
1402+
#### Properties
1403+
1404+
| Property | Type | Required | Description |
1405+
|----------|:----:|:--------:|-------------|
1406+
| id | `string` | `no` | Identifies the event. `source` + `id` is unique for each distinct event.<br>*Required when emitting an event using `emit.event.with`.* |
1407+
| source | `string` | `no` | An URI formatted string, or [runtime expression](dsl.md#runtime-expressions), that identifies the context in which an event happened. `source` + `id` is unique for each distinct event.<br>*Required when emitting an event using `emit.event.with`.* |
1408+
| type | `string` | `no` | Describes the type of event related to the originating occurrence.<br>*Required when emitting an event using `emit.event.with`.* |
1409+
| time | `string` | `no` | A string, or [runtime expression](dsl.md#runtime-expressions), representing the timestamp of when the occurrence happened. |
1410+
| subject | `string` | `no` | Describes the subject of the event in the context of the event producer. |
1411+
| datacontenttype | `string` | `no` | Content type of `data` value. If omitted, it implies the `data` is a JSON value conforming to the "application/json" media type. |
1412+
| dataschema | `string` | `no` | An URI formatted string, or [runtime expression](dsl.md#runtime-expressions), that identifies the schema that `data` adheres to. |
1413+
| data | `object` | `no` | The event payload. |
1414+
1415+
*Additional properties can be supplied, see the Cloud Events specification [documentation](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#extension-context-attributes) for more info.*
1416+
1417+
*When used in an [`eventFilter`](#event-filter), at least one property must be supplied.*
1418+
1419+
13961420
### Event Filter
13971421

13981422
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.
@@ -1401,7 +1425,7 @@ An event filter is a mechanism used to selectively process or handle events base
14011425

14021426
| Property | Type | Required | Description |
14031427
|----------|:----:|:--------:|-------------|
1404-
| with | `object` | `yes` | A name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions. |
1428+
| with | [`eventProperties`](#event-properties) | `yes` | A name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions. |
14051429
| correlate | [`map[string, correlation]`](#correlation) | `no` | A name/definition mapping of the correlations to attempt when filtering events. |
14061430

14071431
### Correlation
@@ -1477,7 +1501,7 @@ When set, runtimes must validate input data against the defined schema, unless d
14771501
| Property | Type | Required | Description |
14781502
|----------|:----:|:--------:|-------------|
14791503
| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate input data.<br>*Even though the schema is not required, it is strongly encouraged to document it, whenever feasible.* |
1480-
| from | `string`<br>`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task input. |
1504+
| from | `string`<br>`object` | `no` | A [runtime expression](dsl.md#runtime-expressions), if any, used to filter and/or mutate the workflow/task input. |
14811505

14821506
#### Examples
14831507

@@ -1506,7 +1530,7 @@ When set, runtimes must validate output data against the defined schema, unless
15061530
| Property | Type | Required | Description |
15071531
|----------|:----:|:--------:|-------------|
15081532
| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate output data.<br>*Even though the schema is not required, it is strongly encouraged to document it, whenever feasible.* |
1509-
| as | `string`<br>`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task output. |
1533+
| as | `string`<br>`object` | `no` | A [runtime expression](dsl.md#runtime-expressions), if any, used to filter and/or mutate the workflow/task output. |
15101534

15111535
#### Examples
15121536

@@ -1640,6 +1664,17 @@ minutes: 15
16401664
seconds: 30
16411665
```
16421666

1667+
### Endpoint
1668+
1669+
Describes an enpoint.
1670+
1671+
#### Properties
1672+
1673+
| Property | Type | Required | Description |
1674+
|----------|:----:|:--------:|-------------|
1675+
| uri | `string` | `yes` | The endpoint's URI. |
1676+
| authentication | `[authentication](#authentication)` | `no` | The authentication policy to use. |
1677+
16431678
### HTTP Response
16441679

16451680
Describes an HTTP response.

dsl.md

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

8282
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.
8383

84-
**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).*
84+
\**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).*
8585

8686
#### Components
8787

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

103103
- [Call](dsl-reference.md#call), used to call services and/or functions.
104104
- [Do](dsl-reference.md#do), used to define one or more subtasks to perform in sequence.
105-
- [Fork](dsl-reference.md#fork), used to define one or more two subtasks to perform in parallel.
106105
- [Emit](dsl-reference.md#emit), used to emit [events](dsl-reference.md#event).
107106
- [For](dsl-reference.md#for), used to iterate over a collection of items, and conditionally perform a task for each of them.
107+
- [Fork](dsl-reference.md#fork), used to define one or more two subtasks to perform in parallel.
108108
- [Listen](dsl-reference.md#listen), used to listen for an [event](dsl-reference.md#event) or more.
109109
- [Raise](dsl-reference.md#raise), used to raise an [error](dsl-reference.md#error) and potentially fault the [workflow](dsl-reference.md#workflow).
110110
- [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).
111-
- [Switch](dsl-reference.md#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions
112111
- [Set](dsl-reference.md#set), used to dynamically set or update the [workflow](dsl-reference.md#workflow)'s data during the its execution.
112+
- [Switch](dsl-reference.md#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions
113113
- [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.
114114
- [Wait](dsl-reference.md#wait), used to pause or wait for a specified duration before proceeding to the next task.
115115

@@ -138,7 +138,7 @@ A workflow begins with the first task defined.
138138

139139
Once the task has been executed, different things can happen:
140140

141-
- `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.
141+
- `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.
142142
- `fault`: the task raised an uncaught error, which abruptly halts the workflow's execution and makes it transition to `faulted` [status phase](#status-phases).
143143
- `end`: the task explicitly and gracefully ends the workflow's execution.
144144

schema/workflow.yaml

Lines changed: 39 additions & 52 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
@@ -369,37 +370,9 @@ $defs:
369370
event:
370371
type: object
371372
properties:
372-
id:
373-
type: string
374-
description: The event's unique identifier
375-
source:
376-
description: Identifies the context in which an event happened
377-
oneOf:
378-
- title: LiteralSource
379-
type: string
380-
format: uri-template
381-
- $ref: '#/$defs/runtimeExpression'
382-
type:
383-
type: string
384-
description: This attribute contains a value describing the type of event related to the originating occurrence.
385-
time:
386-
oneOf:
387-
- title: LiteralTime
388-
type: string
389-
format: date-time
390-
- $ref: '#/$defs/runtimeExpression'
391-
subject:
392-
type: string
393-
datacontenttype:
394-
type: string
395-
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.
396-
dataschema:
397-
oneOf:
398-
- title: LiteralDataSchema
399-
type: string
400-
format: uri-template
401-
- $ref: '#/$defs/runtimeExpression'
402-
required: [ source, type ]
373+
with:
374+
$ref: '#/$defs/eventProperties'
375+
required: [ source, type ]
403376
additionalProperties: true
404377
required: [ event ]
405378
forTask:
@@ -857,6 +830,40 @@ $defs:
857830
$ref: '#/$defs/referenceableAuthenticationPolicy'
858831
description: The authentication policy to use.
859832
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
860867
eventConsumptionStrategy:
861868
type: object
862869
unevaluatedProperties: false
@@ -889,28 +896,8 @@ $defs:
889896
properties:
890897
with:
891898
title: WithEvent
892-
type: object
899+
$ref: '#/$defs/eventProperties'
893900
minProperties: 1
894-
properties:
895-
id:
896-
type: string
897-
description: The event's unique identifier
898-
source:
899-
type: string
900-
description: Identifies the context in which an event happened
901-
type:
902-
type: string
903-
description: This attribute contains a value describing the type of event related to the originating occurrence.
904-
time:
905-
type: string
906-
subject:
907-
type: string
908-
datacontenttype:
909-
type: string
910-
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.
911-
dataschema:
912-
type: string
913-
additionalProperties: true
914901
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.
915902
correlate:
916903
type: object

0 commit comments

Comments
 (0)