From 84941ea33b51bfecebc05e0e0edd0708d1a47b28 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 13 Jun 2024 17:32:34 +0200 Subject: [PATCH 1/2] Documented the task `if` property Signed-off-by: Charles d'Avernas --- dsl-reference.md | 88 +++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 9229708f..005ca263 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -15,9 +15,9 @@ + [HTTP](#http-call) + [OpenAPI](#openapi-call) - [Do](#do) - - [Fork](#fork) - [Emit](#emit) - [For](#for) + - [Fork](#fork) - [Listen](#listen) - [Raise](#raise) - [Run](#run) @@ -242,6 +242,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su | Name | Type | Required | Description| |:--|:---:|:---:|:---| +| if | `string` | `no` | A [`runtime expression`](dsl.md#runtime-expressions), if any, used to determine whether or not the task should be run.
The task is considered skipped if not run. | | 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. | @@ -473,48 +474,6 @@ do: country: Portugal ``` -#### Fork - -Allows workflows to execute multiple subtasks concurrently, enabling parallel processing and improving the overall efficiency of the workflow. By defining a set of subtasks to perform concurrently, the Fork task facilitates the execution of complex operations in parallel, ensuring that multiple tasks can be executed simultaneously. - -##### Properties - -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| fork.branches | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently. | -| 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`. | - -##### Examples - -```yaml -document: - dsl: '1.0.0-alpha1' - namespace: test - name: fork-example - version: '0.1.0' -do: - - raiseAlarm: - fork: - compete: true - branches: - - callNurse: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/nurses - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } - - callDoctor: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/doctor - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } -``` - #### Emit Allows workflows to publish events to event brokers or messaging systems, facilitating communication and coordination between different components and services. With the Emit task, workflows can seamlessly integrate with event-driven architectures, enabling real-time processing, event-driven decision-making, and reactive behavior based on incoming events. @@ -588,6 +547,49 @@ do: as: '.pets + [{ "id": $pet.id }]' ``` +#### Fork + +Allows workflows to execute multiple subtasks concurrently, enabling parallel processing and improving the overall efficiency of the workflow. By defining a set of subtasks to perform concurrently, the Fork task facilitates the execution of complex operations in parallel, ensuring that multiple tasks can be executed simultaneously. + +##### Properties + +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| fork.branches | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently. | +| 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`. | + +##### Examples + +```yaml +document: + dsl: '1.0.0-alpha1' + namespace: test + name: fork-example + version: '0.1.0' +do: + - raiseAlarm: + fork: + compete: true + branches: + - callNurse: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/nurses + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } + - callDoctor: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/doctor + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } +``` + + #### Listen Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems. From f65c7c98e0b878ccb23511bdad2160759b869367 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 13 Jun 2024 17:35:07 +0200 Subject: [PATCH 2/2] Fixed the schema Signed-off-by: Charles d'Avernas --- schema/workflow.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 81fd43d4..88435011 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -112,6 +112,9 @@ $defs: taskBase: type: object properties: + if: + type: string + description: A runtime expression, if any, used to determine whether or not the task should be run. input: $ref: '#/$defs/input' description: Configure the task's input.