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