Siglo provides high-performance combinators for concurrent fan-out, competitive racing, conditional routing, and bounded batch processing.
1. Parallel Fan-Out with parallel()
Execute multiple branches or steps concurrently:
Concurrency Modes & Merge Strategies
Configure merge behavior usingParallelOptions:
$branches and $settled. Note that parallel([...]) is unbounded; for bounded concurrency across large collections, use map() below.
2. Competitive Racing with race()
Execute multiple alternatives concurrently and accept the fastest result:
3. Conditional Branching with branch() and when()
Route execution based on runtime conditions:
Boolean Routing with when(predicate, thenStep, elseStep?)
Ideal for binary branching decisions:
Multi-Way Routing with branch(selectorFn, branchesMap, defaultBranch?)
Ideal for dictionary dispatch across named routes:
4. Bounded Batch Mapping with map()
Process collections with controlled concurrency without exhausting memory or database connections:
Minimal Example
Failure Example: Handling Partial Parallel Failures
UsingallSettled mode ensures individual step errors do not crash other concurrent operations:
Testing Example
Operational Caveats
- Parallel Fan-Out is Unbounded:
parallel([...])initiates all branches simultaneously. When calling external services with limited connection pools, do not useparallel([...])for large arrays—usemap(items, step, { concurrency: N })to bound concurrent executions. - Key Collisions in Parallel Branches: If parallel branches produce identically named output keys without a custom reducer or namespace strategy, the last resolved branch will overwrite prior ones. Specify
{ mergeStrategy: 'namespace' }to isolate branch keys.
