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
// Define one or more steps that optionally return state.
61
-
const files =awaitstep.do('my first step', async () => {
62
-
// Fetch a list of files from $SOME_SERVICE
63
-
return {
64
-
inputParams: event,
65
-
files: [
66
-
'doc_7392_rev3.pdf',
67
-
'report_x29_final.pdf',
68
-
'memo_2024_05_12.pdf',
69
-
'file_089_update.pdf',
70
-
'proj_alpha_v2.pdf',
71
-
'data_analysis_q2.pdf',
72
-
'notes_meeting_52.pdf',
73
-
'summary_fy24_draft.pdf',
74
-
],
75
-
};
76
-
});
77
-
78
-
const apiResponse =awaitstep.do('some other step', async () => {
79
-
let resp =awaitfetch('https://api.cloudflare.com/client/v4/ips');
80
-
returnawaitresp.json<any>();
61
+
const state =awaitstep.do('my first step', async () => {
62
+
return {}
81
63
});
82
64
83
65
awaitstep.sleep('wait on something', '1 minute');
84
66
85
67
awaitstep.do(
86
68
'make a call to write that could maybe, just might, fail',
87
-
// {
88
-
// retries: {
89
-
// limit: 5,
90
-
// delay: '5 second',
91
-
// backoff: 'exponential',
92
-
// },
93
-
// timeout: '15 minutes',
94
-
// },
95
69
async () => {
96
-
// Do stuff here, with access to my_value!
70
+
// Do stuff here, with access to 'state' from the previous step
97
71
if (Math.random() >0.5) {
98
72
thrownewError('API call to $STORAGE_SYSTEM failed');
99
73
}
@@ -106,7 +80,7 @@ export class MyFirstWorkflow implements Workflow {
106
80
A Workflow definition:
107
81
108
82
1. Defines a `run` method that contains the primary logic for your workflow.
109
-
2. Has at least one or more calls to `step.run` that encapsulates the logic of your Workflow.
83
+
2. Has at least one or more calls to `step.do` that encapsulates the logic of your Workflow.
110
84
3. Allows steps to return (optional) state, allowing a Workflow to continue execution even if subsequent steps fail, without having to re-run all previous steps.
111
85
112
86
A single Worker application can contain multiple Workflow definitions, as long as each Workflow has a unique class name. This can be useful for code re-use or to define Workflows are related to each other conceptually.
0 commit comments