Skip to content

Commit b3acb69

Browse files
jmagakGitHub ActionsGerry-Forde
authored
RHIDP-9105: Best practices when creating a workflow (#1424)
* Update the best practices * Update the best practices * Update the best practices * Apply suggestions * Apply new suggestions * Apply new suggestions * Apply new suggestions * Update new suggestions --------- Co-authored-by: GitHub Actions <github-actions@github.com> Co-authored-by: Gerry-Forde <63045020+Gerry-Forde@users.noreply.github.com>
1 parent aba033d commit b3acb69

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

assemblies/assembly-orchestrator-rhdh.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ include::modules/orchestrator/proc-helm-install-components-orchestrator-plugin.a
4545
include::modules/orchestrator/proc-manual-install-components-orchestrator-plugin.adoc[leveloffset=+2]
4646

4747
// {product-very-short} helper script
48-
include::modules/orchestrator/proc-helper-script-overview.adoc[leveloffset=+2]
48+
include::modules/orchestrator/proc-helper-script-overview.adoc[leveloffset=+2]
49+
50+
// best practices when creating workflows
51+
include::modules/orchestrator/ref-best-practices-for-creating-workflows.adoc[leveloffset=+1]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
:_mod-docs-content-type: CONCEPT
2+
3+
[id="ref-best-practices-for-creating-workflows.adoc_{context}"]
4+
= Best practices when creating serverless workflows
5+
6+
Create effective serverless workflows using thoughtful approaches to design, handle data, and manage error by following these best practices based on the Serverless Workflow Domain Specific Language (DSL) principles. These principles help you to build robust workflows.
7+
8+
Workflow design principles::
9+
+
10+
The Serverless Workflow DSL prioritizes clarity and ease of use when writing workflows.
11+
12+
Priority of constituencies:::
13+
+
14+
When developing workflows or APIs, ensure the needs of the author (workflow writer) come first. The constituencies are prioritized in the following order: Authors > Operators > Implementors > Specifications writers.
15+
16+
Linguistic fluency and clarity:::
17+
+
18+
** Use imperative verbs such as `Call`, `Emit`, `For`, `Fork`, `Raise`, `Run`, `Set`, `Switch`, and `Wait`. These simple, universally understood terms make your workflow simple to read and understand.
19+
20+
Structure and extensibility:::
21+
+
22+
** Use implicit default behaviors to reduce redundancy.
23+
** Declare components inline if they are not reusable to keep the definition self-contained.
24+
** Use external references to import and reuse shared components, which promotes a modular design.
25+
** Prioritize flexibility over strict enumerations to ensure extensibility and adaptability across different runtime environments.
26+
27+
Data flow and runtime management::
28+
+
29+
Controlling data flow is critical for efficient workflows. Tasks are the fundamental computing units of a workflow. The Domain Specific Language (DSL) defines several default task types that runtimes must do. These include `Do`, `Listen`, `Raise`, `Run`, `Try`, and `Wait`.
30+
31+
Security and error handling::
32+
+
33+
Secrets::: Use Secrets with caution. Avoid passing them directly in call inputs as this might expose sensitive information.
34+
35+
Fault tolerance and error handling::: Serverless Workflow is designed with resilience in mind to recover from failures.
36+
37+
Orchestrator UI integration best practices::
38+
+
39+
For your workflow results to be effectively displayed in the Orchestrator UI and to facilitate chaining of workflows, you must structure the output data according to the `WorkflowResult` schema. Additionally, include any error information as part of the workflow output so the UI and subsequent workflows can handle them accordingly.
40+
+
41+
Workflow output schema:::
42+
+
43+
Results placement:::: The primary output intended for subsequent processing must be placed under the `data.result` property.
44+
45+
Schema reference:::: Your output schema file (`schemas/workflow-output-schema.json`) must reference the `WorkflowResult` schema.
46+
47+
Outputs definition:::: Include an `outputs` section in your workflow definition. This section contains human-readable key/value pairs that the UI will display.
48+
+
49+
Structure of workflow:
50+
+
51+
[source,yaml]
52+
----
53+
id: my-workflow
54+
version: "0.8"
55+
specVersion: "0.8"
56+
name: My Workflow
57+
start: ImmediatelyEnd
58+
dataInputSchema: schemas/basic__main-schema.json
59+
extensions:
60+
- extensionid: workflow-output-schema
61+
outputSchema: schemas/workflow-output-schema.json
62+
functions:
63+
- name: print
64+
type: custom
65+
operation: sysout
66+
- name: successResult
67+
type: expression
68+
operation: '{
69+
"result": {
70+
"message": "Project " + .projectName + " active",
71+
"outputs":[]
72+
}
73+
}'
74+
start: "successResult"
75+
states:
76+
- name: successResult
77+
type: operation
78+
actions:
79+
- name: setOutput
80+
functionRef:
81+
refName: successResult
82+
end: true
83+
----

0 commit comments

Comments
 (0)