aws / aws/aws-durable-execution-docs
Document parallel short-circuit / early termination pattern
- Dominant language
- Python
- Stars
- 13
- Forks
- 13
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 25
Description
### 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](https://docs.aws.amazon.com/durable-execution/sdk-reference/operations/parallel/#completion-strategies) 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
Contributor guide
Assessment
This issue has not been assessed yet.