From ef35a6eb6ffa545e6bef3375e43151fb671fdd49 Mon Sep 17 00:00:00 2001 From: Nandan Sridhar Date: Sun, 4 Aug 2019 12:09:38 -0700 Subject: [PATCH] remove dupl chl close --- cmd/apis/impapis/impapis.go | 1 - cmd/apps/impapps/impapps.go | 1 - cmd/developers/impdev/impdev.go | 1 - cmd/products/expprod/expprod.go | 22 ++++++++++++++++++++++ cmd/products/impprod/impprod.go | 1 - 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cmd/apis/impapis/impapis.go b/cmd/apis/impapis/impapis.go index 48c0c62d..8aa5644e 100644 --- a/cmd/apis/impapis/impapis.go +++ b/cmd/apis/impapis/impapis.go @@ -110,7 +110,6 @@ func createAPIs(u *url.URL) error { } go func() { wg.Wait() - close(errChan) }() } diff --git a/cmd/apps/impapps/impapps.go b/cmd/apps/impapps/impapps.go index 2ffb3af1..09c90ca3 100644 --- a/cmd/apps/impapps/impapps.go +++ b/cmd/apps/impapps/impapps.go @@ -158,7 +158,6 @@ func createApps() error { } go func() { wg.Wait() - close(errChan) }() } diff --git a/cmd/developers/impdev/impdev.go b/cmd/developers/impdev/impdev.go index a1961c4c..4c2f0e4a 100644 --- a/cmd/developers/impdev/impdev.go +++ b/cmd/developers/impdev/impdev.go @@ -96,7 +96,6 @@ func createDevelopers(url string) error { } go func() { wg.Wait() - close(errChan) }() } diff --git a/cmd/products/expprod/expprod.go b/cmd/products/expprod/expprod.go index dde7deff..642f3463 100644 --- a/cmd/products/expprod/expprod.go +++ b/cmd/products/expprod/expprod.go @@ -78,6 +78,28 @@ func exportProducts() error { wg.Wait() close(errChan) }() + } else { + numOfLoops, remaining := numProd/conn, numProd%conn + for i := 0; i < numOfLoops; i++ { + shared.Info.Printf("Create %d batch of products\n", i) + wg.Add(conn) + for j := 0; j < conn; j++ { + go shared.GetAsyncEntity(url.PathEscape(products.APIProducts[j+(i*conn)].Name), entityType, &wg, &mu, errChan) + } + go func() { + wg.Wait() + }() + } + + wg.Add(remaining) + shared.Info.Printf("Create remaining %d products\n", remaining) + for i := (numProd - remaining); i < numProd; i++ { + go shared.GetAsyncEntity(url.PathEscape(products.APIProducts[i].Name), entityType, &wg, &mu, errChan) + } + go func() { + wg.Wait() + close(errChan) + }() } //print any errors and return an err diff --git a/cmd/products/impprod/impprod.go b/cmd/products/impprod/impprod.go index 355767d1..8f2b5407 100644 --- a/cmd/products/impprod/impprod.go +++ b/cmd/products/impprod/impprod.go @@ -98,7 +98,6 @@ func createProducts(url string) error { } go func() { wg.Wait() - close(errChan) }() }