Skip to content

Document parallel short-circuit / early termination pattern #148

@yaythomas

Description

@yaythomas

Problem

A common use case is running N parallel validation tasks where any single "reject" result should immediately short-circuit the remaining tasks. This is different from Promise.race() (first to finish wins) — it is about early termination based on a business logic outcome.

CompletionConfig and completion strategies can be used here, and the toleratedFailureCount parameter can serve as a workaround (treating a reject as a thrown error to trigger early completion), but this pattern is not documented.

Current state

The parallel operations docs document CompletionConfig and mechanical completion modes, but there is no recipe or pattern for "short-circuit on business logic." The toleratedFailureCount workaround is not documented as a pattern.

Suggested improvement

  • Add a pattern/recipe to the best practices or patterns docs: "Early termination of parallel tasks based on business logic"
  • Document the toleratedFailureCount workaround with a concrete example (e.g., a content validation engine with checks that may involve long-running IO)
  • Consider linking to the parallel-race CDK example if publicly available

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions