Skip to content

Latest commit

 

History

History
70 lines (41 loc) · 1.54 KB

File metadata and controls

70 lines (41 loc) · 1.54 KB

Home > @aws/durable-execution-sdk-js > DurableContext > parallel

DurableContext.parallel() method

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>>;

Parameters

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>>

Example

// Strict: all branches must return string
const results = await context.parallel<string>([
  async (ctx) => ctx.step(async () => "task1"),
  async (ctx) => ctx.step(async () => "task2"),
]);