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/examples/dynamic-workflows.mdx
+60-47Lines changed: 60 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ For example, an AI agent might decide at runtime to create a Workflow with these
18
18
19
19
With Dynamic Workers and Workflows, the Worker Loader, which loads Dynamic Workers, can create that Workflow on the spot, run it durably, and let Workflows handle retries, sleeping, and waiting for events. You do not need to pre-register a separate Workflow class for every run.
20
20
21
+
In this example, we'll set up a simple Dynamic Workflow which allows you to run arbitrary Workflows code at runtime.
22
+
21
23
## When to use this pattern
22
24
23
25
Use this pattern when your workflow logic is not known at deploy time.
@@ -80,7 +82,7 @@ Your Worker needs two things:
80
82
81
83
Although the Workflow is not statically defined, you still deploy one normal Workflow class. Its job is to load the dynamic code for the current run and call it with the `WorkflowStep` object. This class is what makes the [Workflows API](/workflows/build/workers-api/), including `step.do()`, `step.sleep()`, and `step.waitForEvent()`, continue to work as normal.
82
84
83
-
Use `env.LOADER.get(id, callback)` via the [Worker Loader API](/dynamic-workers/api-reference/#load) to create the Dynamic Worker. If the Dynamic Worker has already been created, the Worker Loader uses its `workerId` to reload the code and use the same Dynamic Worker.
85
+
Use `env.LOADER.get()` via the [Worker Loader API](/dynamic-workers/api-reference/#load) to create the Dynamic Worker. If the Dynamic Worker has already been created, the Worker Loader uses its `workerId` to reload the code and use the same Dynamic Worker.
0 commit comments