fix: preserve empty parallel executor context

- hoist the empty executor guard out of the inner closure to match NewPipelineExecutor
- preserve canceled context semantics when no executors are provided
- add coverage for the empty executor case
This commit is contained in:
Lunny Xiao
2026-05-12 21:07:59 -07:00
parent f23605c614
commit 60b0a6297e
2 changed files with 20 additions and 0 deletions

View File

@@ -97,6 +97,12 @@ func NewErrorExecutor(err error) Executor {
// NewParallelExecutor creates a new executor from a parallel of other executors
func NewParallelExecutor(parallel int, executors ...Executor) Executor {
if len(executors) == 0 {
return func(ctx context.Context) error {
return ctx.Err()
}
}
return func(ctx context.Context) error {
work := make(chan Executor, len(executors))
errs := make(chan error, len(executors))