diff --git a/common/task/task.go b/common/task/task.go index f79e5610a..5a6763959 100644 --- a/common/task/task.go +++ b/common/task/task.go @@ -88,8 +88,8 @@ func OnFailure(task Task) ExecutionOption { } } -func Single(task Task, opts ExecutionOption) Task { - return Run(append([]ExecutionOption{Sequential(task)}, opts)...) +func Single(task Task, opts ...ExecutionOption) Task { + return Run(append([]ExecutionOption{Sequential(task)}, opts...)...) } func Run(opts ...ExecutionOption) Task { @@ -120,14 +120,17 @@ func executeParallel(ctx context.Context, tasks []Task) error { for _, task := range tasks { <-s.Wait() - go func(f func() error) { - if err := f(); err != nil { - select { - case done <- err: - default: - } + go func(f Task) { + err := f() + if err == nil { + s.Signal() + return + } + + select { + case done <- err: + default: } - s.Signal() }(task) }