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