From 4784540f049060cb992cbbf2b36819a3d6438703 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 8 Mar 2020 20:48:51 +0100 Subject: [PATCH] repository: Simplify worker group code --- internal/checker/checker.go | 2 +- internal/repository/repository.go | 2 +- internal/repository/worker_group.go | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 8b3ca9695..1f3233a01 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -142,7 +142,7 @@ func (c *Checker) LoadIndex(ctx context.Context) (hints []error, errs []error) { // run workers on ch wg.Go(func() error { - return repository.RunWorkers(ctx, defaultParallelism, worker, final) + return repository.RunWorkers(defaultParallelism, worker, final) }) // receive decoded indexes diff --git a/internal/repository/repository.go b/internal/repository/repository.go index e25bf369e..72fc423c3 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -479,7 +479,7 @@ func (r *Repository) LoadIndex(ctx context.Context) error { // run workers on ch wg.Go(func() error { - return RunWorkers(ctx, loadIndexParallelism, worker, final) + return RunWorkers(loadIndexParallelism, worker, final) }) // receive decoded indexes diff --git a/internal/repository/worker_group.go b/internal/repository/worker_group.go index 52988f0bd..a87ef4f49 100644 --- a/internal/repository/worker_group.go +++ b/internal/repository/worker_group.go @@ -1,8 +1,6 @@ package repository import ( - "context" - "golang.org/x/sync/errgroup" ) @@ -10,8 +8,8 @@ import ( // After all workers have terminated, finalFunc is run. If an error occurs in // one of the workers, it is returned. FinalFunc is always run, regardless of // any other previous errors. -func RunWorkers(ctx context.Context, count int, workerFunc func() error, finalFunc func()) error { - wg, _ := errgroup.WithContext(ctx) +func RunWorkers(count int, workerFunc func() error, finalFunc func()) error { + var wg errgroup.Group // run workers for i := 0; i < count; i++ {