Skip to content

Commit 82c1313

Browse files
authored
script_name (#17770)
1 parent 90009ca commit 82c1313

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
// Trigger our Workflow
3535
// Pass our event as the second parameter to the `create` method
3636
// on our Workflow binding.
37-
let instance = await env.MYWORKFLOW.create({
37+
let instance = await env.MY_WORKFLOW.create({
3838
id: await crypto.randomUUID(),
3939
params: someEvent
4040
});

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,36 @@ compatibility_date = "2024-10-22"
116116
[[workflows]]
117117
# name of your workflow
118118
name = "workflows-starter"
119-
# binding name env.MYWORKFLOW
119+
# binding name env.MY_WORKFLOW
120120
binding = "MY_WORKFLOW"
121121
# this is class that extends the Workflow class in src/index.ts
122122
class_name = "MyWorkflow"
123123
```
124124

125+
### Cross-script calls
126+
127+
You can also bind to a Workflow that is defined in a different Worker script from the script your Workflow definition is in. To do this, provide the `script_name` key with the name of the script to the `[[workflows]]` binding definition in your `wrangler.toml` configuration.
128+
129+
For example, if your Workflow is defined in a Worker script named `billing-worker`, but you are calling it from your `web-api-worker` script, your `wrangler.toml` would resemble the following:
130+
131+
```toml title="wrangler.toml"
132+
#:schema node_modules/wrangler/config-schema.json
133+
name = "web-api-worker"
134+
main = "src/index.ts"
135+
compatibility_date = "2024-10-22"
136+
137+
[[workflows]]
138+
# name of your workflow
139+
name = "billing-workflow"
140+
# binding name env.MY_WORKFLOW
141+
binding = "MY_WORKFLOW"
142+
# this is class that extends the Workflow class in src/index.ts
143+
class_name = "MyWorkflow"
144+
# the script name where the Workflow is defined.
145+
# required if the Workflow is defined in another script.
146+
script_name = "billing-worker"
147+
```
148+
125149
## Workflow
126150

127151
:::note

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ To bind a Workflow to a Worker, you need to define a `[[workflows]]` binding in
176176
[[workflows]]
177177
# name of your workflow
178178
name = "workflows-starter"
179-
# binding name env.MYWORKFLOW
179+
# binding name env.MY_WORKFLOW
180180
binding = "MY_WORKFLOW"
181181
# this is class that extends the Workflow class in src/index.ts
182182
class_name = "MyWorkflow"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ compatibility_date = "2024-10-22"
194194
[[workflows]]
195195
# name of your workflow
196196
name = "workflows-starter"
197-
# binding name env.MYWORKFLOW
197+
# binding name env.MY_WORKFLOW
198198
binding = "MY_WORKFLOW"
199199
# this is class that extends the Workflow class in src/index.ts
200200
class_name = "MyWorkflow"

0 commit comments

Comments
 (0)