Skip to content

Commit 2b39e8c

Browse files
committed
Added Workflow instances batch creation instructions
1 parent 74f68bf commit 2b39e8c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,28 @@ export default {
266266
}
267267
```
268268

269+
### createBatch
270+
271+
Create (trigger) a batch of new instance of the given Workflow, up to 100 instances at a time.
272+
273+
* <code>createBatch(batch: WorkflowInstanceCreateOptions[]): Promise&lt;WorkflowInstance[]&gt;</code>
274+
275+
* `batch` - list of Options to pass when creating an instance, including a user-provided ID and payload parameters.
276+
277+
Each element of the `batch` list is expected to the
278+
279+
```ts
280+
// Create a new batch of 3 Workflow instances, each with its own ID and pass params to the Workflow instances
281+
const listOfInstances = [
282+
{ id: "idFromBatch0", params: { "hello": "world-0" } },
283+
{ id: "idFromBatch1", params: { "hello": "world-1" } },
284+
{ id: "idFromBatch2", params: { "hello": "world-2" } }
285+
];
286+
let instances = await env.MY_WORKFLOW.createBatch(listOfInstances);
287+
```
288+
289+
Returns a list of `WorkflowInstance`.
290+
269291
### get
270292

271293
Get a specific Workflow instance by ID.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ class_name = "MyWorkflow"
188188
You can then invoke the methods on this binding directly from your Worker script's `env` parameter. The `Workflow` type has methods for:
189189

190190
* `create()` - creating (triggering) a new instance of the Workflow, returning the ID.
191+
* `createBatch()` - creating (triggering) a batch of new instances of the Workflow, returning the IDs.
191192
* `get()`- retrieve a Workflow instance by its ID.
192193
* `status()` - get the current status of a unique Workflow instance.
193194

0 commit comments

Comments
 (0)