Skip to content

Commit 0fc5105

Browse files
committed
more
1 parent e0c3786 commit 0fc5105

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/content/docs/workflows/build/events-and-parameters.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ When a Workflow is triggered, it can receive an optional event. This event can i
1010

1111
Events are a powerful part of a Workflow, as you often want a Workflow to act on data. Because a given Workflow instance executes durably, events are a useful way to provide a Workflow with data that should be immutable (not changing) and/or represents data the Workflow needs to operate on at that point in time.
1212

13-
## Passing parameters
13+
## Passing parameters to a Workflow
1414

1515
You can pass parameters to a Workflow in two ways:
1616

@@ -55,7 +55,7 @@ npx wrangler@latest workflows trigger workflows-starter '{"some":"data"}'
5555
🚀 Workflow instance "57c7913b-8e1d-4a78-a0dd-dce5a0b7aa30" has been queued successfully
5656
```
5757

58-
## TypeScript and typing events
58+
## TypeScript and type parameters
5959

6060
By default, the `WorkflowEvent` passed to the `run` method of your Workflow definition has a type that conforms to the following, with `payload` (your data) and `timestamp` properties:
6161

src/content/docs/workflows/build/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Build with Workflows
33
pcx_content_type: navigation
44
sidebar:
5-
order: 1
5+
order: 2
66

77
---
88

src/content/docs/workflows/get-started/cli-quick-start.mdx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ You can build Workflows to post-process file uploads to [R2 object storage](/r2/
2323

2424
## Prerequisites
2525

26-
:::note
26+
:::caution
2727

2828
This guide is for users who are already familiar with Cloudflare Workers and [durable execution](/workflows/reference/how-workflows-works/) programming models.
2929

30-
If you're new to either, we recommend the [introduction to Workflows](/workflows/get-started/guide/) guide, which steps through how a Workflow is defined, how to persist state, deploy and manage Workflows.
30+
If you're new to either, we recommend the [introduction to Workflows](/workflows/get-started/guide/) guide, which steps through how a Workflow is defined, how to persist state, and how to deploy and run your first Workflow.
3131

3232
:::
3333

@@ -44,7 +44,7 @@ Workflows are defined as part of a Worker script.
4444
To create a Workflow, use the `create cloudflare` (C3) CLI tool, specifying the Workflows starter template:
4545

4646
```sh
47-
npm create cloudflare@latest workflows-tutorial -- --template "cloudflare:workflows-tutorial"
47+
npm create cloudflare@latest workflows-starter -- --template "cloudflare:workflows-starter"
4848
```
4949

5050
This will create a new folder called `workflows-tutorial`, which contains two files:
@@ -56,20 +56,28 @@ Open the `src/index.ts` file in your text editor. This file contains the followi
5656

5757
```ts title="src/index.ts"
5858
// Import the Workflow definition
59-
import { Workflow, WorkflowEvent, WorkflowStep } from "cloudflare:workflows"
59+
import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from "cloudflare:workflows"
6060

6161
// Create your own class that implements a Workflow
62-
export class MyFirstWorkflow implements Workflow {
62+
export class MyWorkflow implements WorkflowEntrypoint {
6363
// Define a run() method
6464
async run(event: WorkflowEvent, step: WorkflowStep) {
6565
// Define one or more steps that optionally return state.
66-
let state = step.do("my first step", async () => {
67-
68-
})
69-
70-
step.do("my second step", async () => {
71-
72-
})
66+
const state = await step.do('my first step', async () => {
67+
return {}
68+
});
69+
70+
await step.sleep('wait on something', '1 minute');
71+
72+
await step.do(
73+
'make a call to write that could maybe, just might, fail',
74+
async () => {
75+
// Do stuff here, with access to 'state' from the previous step
76+
if (Math.random() > 0.5) {
77+
throw new Error('API call to $STORAGE_SYSTEM failed');
78+
}
79+
}
80+
);
7381
}
7482
}
7583
```
@@ -81,7 +89,7 @@ Specifically:
8189
3. TODO - how state is persisted
8290
4. TODO - retries and config
8391
5. TODO - triggering from a fetch handler
84-
92+
8593
```ts title="src/index.ts"
8694

8795

0 commit comments

Comments
 (0)