From 8ed119e3f60099d7c232a30efa9d474aff3bc8db Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 5 Aug 2018 17:56:49 +0200 Subject: [PATCH] make sure err is propagated --- common/task/task.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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) }