You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workflows/build/rules-of-steps.mdx
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
-
title: Rules of Steps
2
+
title: Rules of Workflows
3
3
pcx_content_type: concept
4
4
sidebar:
5
5
order: 10
6
6
---
7
7
8
-
A Workflow step is self-contained, individually retriable component of a Workflow. Steps may emit (optional) state that allows a Workflow to persist and continue from that step, even if a Workflow fails due to a network or infrastructure issue. A Workflow is comprised of one or more steps.
8
+
A Workflow contains one or more steps. Each step is a self-contained, individually retriable component of a Workflow. Steps may emit (optional) state that allows a Workflow to persist and continue from that step, even if a Workflow fails due to a network or infrastructure issue. A Workflow is comprised of one or more steps.
9
9
10
10
This is a small guidebook on how to build more resilient and correct Workflows.
11
11
@@ -18,8 +18,8 @@ As an example, let's assume you have a Workflow that charges your customers and
Guaranteeing idempotency might be optional in your specific use-case and implementaion, although we recommend it to always try to guarantee it.
58
+
Guaranteeing idempotency might be optional in your specific use-case and implementation, although we recommend it to always try to guarantee it.
59
59
60
60
:::
61
61
62
62
### Make your steps granular
63
63
64
64
Steps should be as self-contained as possible, this allows your own logic to be more durable in case of failures in third-party APIs, network errors, and so on.
65
+
65
66
You can also think of it as a transaction, or a unit of work.
66
67
67
68
- ✅ Minimize the number of API/binding calls per step (unless you need multiple calls to prove idempotency).
Sometimes, our Engine will hibernate and lose all in-memory state - this will happen when engine detects that there's no pending work and can hibernate
111
-
until it needs to wake-up (because of a sleep, retry or event). This means that you can't do something like this:
111
+
Workflows may hibernate and lose all in-memory state. This will happen when engine detects that there's no pending work and can hibernate until it needs to wake-up (because of a sleep, retry or event).
112
+
113
+
This means that you should not store state outside of a step:
112
114
113
115
```ts
114
116
function getRandomInt(min, max) {
@@ -117,8 +119,8 @@ function getRandomInt(min, max) {
117
119
returnMath.floor(Math.random() * (maxFloored-minCeiled) +minCeiled); // The maximum is exclusive and the minimum is inclusive
0 commit comments