Home > @aws/durable-execution-sdk-js > DurableContext > parallel
Executes multiple branches with durable operations in parallel with optional concurrency control
Signature:
parallel<TOutput>(branches: (ParallelFunc<TOutput, TLogger> | NamedParallelBranch<TOutput, TLogger>)[], config?: ParallelConfig<TOutput>): DurablePromise<BatchResult<TOutput>>;|
Parameter |
Type |
Description |
|---|---|---|
|
branches |
(ParallelFunc<TOutput, TLogger> | NamedParallelBranch<TOutput, TLogger>)[] |
Array of functions or named branches to execute in parallel (all must return same type) |
|
config |
ParallelConfig<TOutput> |
(Optional) Optional configuration for concurrency and completion behavior |
Returns:
DurablePromise<BatchResult<TOutput>>
// Strict: all branches must return string
const results = await context.parallel<string>([
async (ctx) => ctx.step(async () => "task1"),
async (ctx) => ctx.step(async () => "task2"),
]);