Cloudflare Workflows v2026-10-08:createBatch支持批量创建
Workflows, Workers - Create Workflow instance batches by count or list
涉及核心 API 接口弃用(数组传参)与新能力引入,依赖 Cloudflare Workflows 的开发者必须关注此变更以避免未来兼容性问题,建议尽快迁移至新的 options 对象模式。
createBatch() now accepts an options object that creates up to 100 Workflow instances in one call. The result lists the created instances and explains why any others were not created. To use this form in local development and get its types from wrangler types, use Wrangler 4.148.0 or later.
createBatch() 现在接受一个 options 对象,可在一次调用中创建最多 100 个 Workflow 实例。结果列表会列出已创建的实例,并解释为何其他实例未被创建。要在本地开发中使用此形式并从 wrangler types 获取其类型,请使用 Wrangler 4.148.0 或更高版本。
To create instances that share the same options, pass count. Each instance receives a generated ID:
要创建共享相同选项的实例,请传递 count。每个实例都会获得一个生成的 ID:
const result = await env.MY_WORKFLOW.createBatch({
count: 10,
params: { report: "daily" },
});const result = await env.MY_WORKFLOW.createBatch({
count: 10,
params: { report: "daily" },
});To give each instance its own ID or options, pass instances:
要为每个实例指定自己的 ID 或选项,请传递 instances:
const { created, errors } = await env.MY_WORKFLOW.createBatch({
instances: [
{ id: "order-1", params: { orderId: 1 } },
{ id: "order-2", params: { orderId: 2 } },
],
});
for (const error of errors) {
console.log(error.index, error.id, error.code, error.message);
}const { created, errors } = await env.MY_WORKFLOW.createBatch({
instances: [
{ id: "order-1", params: { orderId: 1 } },
{ id: "order-2", params: { orderId: 2 } },
],
});
for (const error of errors) {
console.log(error.index, error.id, error.code, error.message);
}created contains the created instances. errors contains each entry that was not created, identified by its position in the input. IDs that already exist and IDs repeated within the batch are reported as errors instead of being skipped silently.
created 包含已创建的实例。errors 包含每个未创建的条目,并通过其在输入中的位置进行标识。已存在的 ID 以及在批次内重复的 ID 会被报告为错误,而不是被静默跳过。
Passing an array to createBatch() is deprecated. Existing code that uses the array form continues to work.
向 createBatch() 传递数组的做法已被弃用。使用数组形式的现有代码仍可继续正常工作。
For more information, refer to createBatch.
更多信息,请参阅 createBatch。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力