Skip to content

Commit 08bff08

Browse files
Fix some typos
1 parent 15720df commit 08bff08

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

src/content/docs/workflows/build/rules-of-workflows.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ check if they were already charged:
1919

2020
```ts
2121
export class MyWorkflow extends WorkflowEntrypoint {
22-
async run(event: WorkflowEvent, step: WorkflowStep) {
22+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
2323
const customer_id = 123456;
2424
// ✅ Good: Non-idempotent API/Binding calls are always done **after** checking if the operation is
2525
// still needed.
@@ -69,7 +69,7 @@ You can also think of it as a transaction, or a unit of work.
6969

7070
```ts
7171
export class MyWorkflow extends WorkflowEntrypoint {
72-
async run(event: WorkflowEvent, step: WorkflowStep) {
72+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
7373
// ✅ Good: Unrelated API/Binding calls are self-contained, so that in case one of them fails
7474
// it can retry them individually. It also has an extra advantage: you can control retry or
7575
// timeout policies for each granular step - you might not to want to overload http.cat in
@@ -94,7 +94,7 @@ Otherwise, your entire Workflow might not be as durable as you might think, and
9494

9595
```ts
9696
export class MyWorkflow extends WorkflowEntrypoint {
97-
async run(event: WorkflowEvent, step: WorkflowStep) {
97+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
9898
// 🔴 Bad: you're calling two seperate services from within the same step. This might cause
9999
// some extra calls to the first service in case the second one fails, and in some cases, makes
100100
// the step non-idempotent altogether
@@ -120,7 +120,7 @@ function getRandomInt(min, max) {
120120
}
121121

122122
export class MyWorkflow extends WorkflowEntrypoint {
123-
async run(event: WorkflowEvent, step: WorkflowStep) {
123+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
124124
// 🔴 Bad: `imageList` will be not persisted across engine's lifetimes. Which means that after hibernation,
125125
// `imageList` will be empty again, even though the following two steps have already ran.
126126
const imageList: string[] = [];
@@ -163,7 +163,7 @@ function getRandomInt(min, max) {
163163
}
164164

165165
export class MyWorkflow extends WorkflowEntrypoint {
166-
async run(event: WorkflowEvent, step: WorkflowStep) {
166+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
167167
// ✅ Good: imageList state is exclusively comprised of step returns - this means that in the event of
168168
// multiple engine lifetimes, imageList will be built accordingly
169169
const imageList: string[] = await Promise.all([
@@ -231,7 +231,7 @@ Dynamically naming a step will prevent it from being cached, and cause the step
231231
232232
```ts
233233
export class MyWorkflow extends WorkflowEntrypoint {
234-
async run(event: WorkflowEvent, step: WorkflowStep) {
234+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
235235
// 🔴 Bad: Dynamically naming the step prevents it from being cached
236236
// This will cause the step to be re-run if subsequent steps fail.
237237
await step.do(`step #1 running at: ${Date.now}`, async () => {

src/content/docs/workflows/build/sleeping-and-retrying.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ This can be useful when you detect a terminal (permanent) error from an upstream
9595
9696
```ts
9797
// Import the NonRetryableError definition
98-
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent, NonRetryableError } from 'cloudflare:workers';
98+
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent } from 'cloudflare:workers';
99+
import { NonRetryableError } from 'cloudflare:workflows';
99100
100101
// In your step code:
101102
export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {

src/content/docs/workflows/build/trigger-workflows.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default {
8080
// Else, create a new instance of our Workflow, passing in any (optional) params
8181
// and return the ID.
8282
const newId = await crypto.randomUUID();
83-
let instance = await env.MY_WORKFLOW.create(newId, {});
83+
let instance = await env.MY_WORKFLOW.create({ id: newId });
8484
return Response.json({
8585
id: instance.id,
8686
details: await instance.status(),

src/content/docs/workflows/build/workers-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ For example, to bind to a Workflow called `workflows-starter` and to make it ava
111111
#:schema node_modules/wrangler/config-schema.json
112112
name = "workflows-starter"
113113
main = "src/index.ts"
114-
compatibility_date = "2024-10-16"
114+
compatibility_date = "2024-10-22"
115115

116116
[[workflows]]
117117
# name of your workflow

src/content/docs/workflows/get-started/guide.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ Open the `src/index.ts` file in your text editor. This file contains the followi
4949
// Import the Workflow definition
5050
import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from "cloudflare:workers"
5151

52+
type Params = {}
53+
5254
// Create your own class that implements a Workflow
53-
export class MyWorkflow implements WorkflowEntrypoint {
55+
export class MyWorkflow extends WorkflowEntrypoint {
5456
// Define a run() method
55-
async run(event: WorkflowEvent, step: WorkflowStep) {
57+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
5658
// Define one or more steps that optionally return state.
5759
const state = await step.do('my first step', async () => {
5860
return {}
@@ -99,10 +101,12 @@ At its most basic, a step looks like this:
99101
// Import the Workflow definition
100102
import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from "cloudflare:workers"
101103

104+
type Params = {}
105+
102106
// Create your own class that implements a Workflow
103-
export class MyWorkflow implements WorkflowEntrypoint {
107+
export class MyWorkflow extends WorkflowEntrypoint {
104108
// Define a run() method
105-
async run(event: WorkflowEvent, step: WorkflowStep) {
109+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
106110
// Define one or more steps that optionally return state.
107111
let state = step.do("my first step", async () => {
108112

@@ -150,7 +154,7 @@ Open the `wrangler.toml` file at the root of your `workflows-starter` folder, wh
150154
#:schema node_modules/wrangler/config-schema.json
151155
name = "workflows-starter"
152156
main = "src/index.ts"
153-
compatibility_date = "2024-10-23"
157+
compatibility_date = "2024-10-22"
154158

155159
[[workflows]]
156160
# name of your workflow

0 commit comments

Comments
 (0)