This feature is not yet available in
workflow-py. See our
Roadmap for feature parity plans and
Changelog for updates.
Promise.all, you can run multiple workflow steps at the same time:
app/api/workflow/route.ts
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Run multiple Upstash Workflow steps at the same time with Promise.all, executing independent steps concurrently within a single run.
Promise.all, you can run multiple workflow steps at the same time:
const [result1, result2, result3] =
await Promise.all([
ctx.run("parallel-step-1", async () => { ... }),
ctx.run("parallel-step-2", async () => { ... }),
ctx.run("parallel-step-3", async () => { ... }),
])
import { serve } from "@upstash/workflow/nextjs";
import { checkInventory, brewCoffee, printReceipt } from "@/utils";
export const { POST } = serve(async (ctx) => {
const [coffeeBeansAvailable, cupsAvailable, milkAvailable] =
await Promise.all([
ctx.run("check-coffee-beans", () => checkInventory("coffee-beans")),
ctx.run("check-cups", () => checkInventory("cups")),
ctx.run("check-milk", () => checkInventory("milk")),
]);
// If all ingedients available, brew coffee
if (coffeeBeansAvailable && cupsAvailable && milkAvailable) {
const price = await ctx.run("brew-coffee", async () => {
return await brewCoffee({ style: "cappuccino" });
});
await printReceipt(price);
}
});
Was this page helpful?