Skip to content

Commit 5742ac3

Browse files
GitHub Actionsjmagak
authored andcommitted
Update the best practices
1 parent 04f0e0c commit 5742ac3

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

modules/orchestrator/con-best-practices-for-creating-workflows.adoc

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,88 @@
33
[id="con-best-practices-for-creating-workflows.adoc_{context}"]
44
= Best practices when creating a workflow
55

6-
Review the following best practices when you create a seamless integration of workflows with the {product-custom-resource-type} Orchestrator UI and adherence to Serverless Workflow DSL principles. You can apply one or more of these practices in your environment.
6+
Here are some best practices when creating workflows while adhering to Serverless Workflow DSL principles.
7+
8+
Workflow design principles based on Serverless Workflow (DSL)::
9+
10+
The Serverless Workflow Domain Specific Language (DSL) prioritizes clarity and ease of use.
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 as follows: Authors > Operators > Implementors > Specifications writers.
15+
16+
* Linguistic fluency and clarity
17+
+
18+
** Embrace linguistic fluency for enhanced readability and understanding.
19+
** Utilize imperative verbs to convey actions directly and clearly.
20+
** Opt for universally understood terms to improve accessibility and comprehension, avoiding technical jargon wherever possible.
21+
22+
* Structure and Extensibility
23+
+
24+
** Employ implicit default behaviors to reduce redundancy and streamline workflow definitions, sparing authors from unnecessary repetition.
25+
** Encourage the declaration of components inline for situations where reusability is unnecessary.
26+
** Enable the declaration and effortless import of shared components by supporting external references.
27+
** Prioritize flexibility over strong-typed enumerations for enhanced extensibility and adaptability across different runtime environments.
28+
29+
Data flow and runtime management::
30+
31+
. Tasks and execution
32+
+
33+
** Tasks are the fundamental computing units of a workflow. The DSL defines several default task types that runtimes must implement, including `Call`, `Do`, `Emit`, `For`, `Fork`, `Listen`, `Raise`, `Run`, `Set`, `Switch`, `Try`, and `Wait`.
34+
35+
. Data transformations
36+
+
37+
To ensure data flows in a controlled and efficient manner, transformations can be applied at strategic points:
38+
39+
** Workflow Input Validation/Transformation: Before the workflow starts, validate input data against the `input.schema`. Input data can be transformed using the top-level `input.from` expression to pass only relevant data to the workflow context.
40+
** Task Input/Output Transformation: Before a task executes, its input can be transformed using the task's `input.from` expression to match specific task requirements. After the task completes, its output can be transformed using the `output.as` runtime expression before being passed to the next task.
41+
** Context Management: Use the `export.as` runtime expression to update the workflow's context. This evaluates the transformed task output, helping to keep the context clean by removing unnecessary data.
42+
** Workflow output transformation: Finally, transform the overall workflow output using `output.as` before returning it to the caller, ensuring the final output is concise and relevant.
43+
44+
. Security (Secrets)
45+
+
46+
** Use secrets with caution: Incorporating secrets in expressions or passing them as call inputs may inadvertently expose sensitive information.
47+
** Secrets can only be used in the `input.from` runtime expression to prevent unintentional bleeding.
48+
49+
Fault tolerance and error handling::
50+
51+
Serverless Workflow is designed with resilience in mind to recover gracefully from failures.
52+
53+
** Error Description: Errors should be described using the **Problem Details RFC**. The `instance` property should be used as a JSON Pointer to identify the specific component that raised the error.
54+
** Standard Errors: Use standard error types defined by the specification (e.g., timeouts) to ensure consistent behavior across different runtimes.
55+
** Retries: For transient errors (like a 503 `Service Unavailable`), utilize the built-in mechanism to **retry a faulted task** (via a `try` block) to allow for graceful recovery.
56+
** Timeouts: Workflows and tasks can be configured to timeout. Upon timeout, execution must be interrupted, and an error must be raised with the type **`https://serverlessworkflow.io/spec/1.0.0/errors/timeout`** and status **408**.
57+
58+
Orchestrator UI integration best practices::
59+
60+
To effectively display results, output generated by the user interface, or facilitate the chaining of workflow executions, the workflow must deliver its output data in a recognized structured format defined by the `WorkflowResult` schema.
61+
62+
. Workflow output schema
63+
+
64+
.. Placement of Results: The output intended for next processing **should be placed under the `data.result` property**.
65+
.. Schema Reference: The output schema file (`schemas/workflow-output-schema.json`) should reference the `WorkflowResult` schema.
66+
.. Outputs Definition: Include an `outputs` section in the workflow definition containing human-readable key/value pairs that will be displayed in the UI.
67+
+
68+
.Example structure for workflow output data injection:
69+
70+
[source,yaml]
71+
----
72+
states:
73+
- name: ImmediatelyEnd
74+
type: inject
75+
data:
76+
result:
77+
message: A human-readable description of the successful status. Or an error.
78+
outputs:
79+
- key: Foo Bar human readable name which will be shown in the UI
80+
value: Example string value produced on the output. This might be an input for a next workflow.
81+
nextWorkflows:
82+
- id: my-next-workflow-id
83+
name: Next workflow name suggested if this is an assessment workflow. Human readable, it's text does not need to match true workflow name.
84+
end: true
85+
----
86+
87+
88+
. Deprecation notice for workflow types
89+
+
90+
** Deprecation Notice: From Orchestrator release version 1.7, Workflow Types will be retired. All workflows will act as infrastructure workflows, and no workflow will act as an assessment workflow. Any references to assessment workflows (such as in the `nextWorkflows` property example above) will become obsolete.

0 commit comments

Comments
 (0)