(httpClient *http.Client, hostname string, uploadURL safeurl.SafeURL, numWorkers int, assets []*AssetForUpload)
| 109 | } |
| 110 | |
| 111 | func ConcurrentUpload(httpClient *http.Client, hostname string, uploadURL safeurl.SafeURL, numWorkers int, assets []*AssetForUpload) error { |
| 112 | if numWorkers == 0 { |
| 113 | return errors.New("the number of concurrent workers needs to be greater than 0") |
| 114 | } |
| 115 | |
| 116 | ctx := context.Background() |
| 117 | g, gctx := errgroup.WithContext(ctx) |
| 118 | g.SetLimit(numWorkers) |
| 119 | |
| 120 | for _, a := range assets { |
| 121 | asset := *a |
| 122 | g.Go(func() error { |
| 123 | return uploadWithDelete(gctx, httpClient, hostname, uploadURL, asset) |
| 124 | }) |
| 125 | } |
| 126 | |
| 127 | return g.Wait() |
| 128 | } |
| 129 | |
| 130 | func shouldRetry(err error) bool { |
| 131 | var networkError errNetwork |
no test coverage detected