MCPcopy Create free account
hub / github.com/cli/cli / ConcurrentUpload

Function ConcurrentUpload

pkg/cmd/release/shared/upload.go:115–132  ·  view source on GitHub ↗
(httpClient httpDoer, uploadURL safeurl.SafeURL, numWorkers int, assets []*AssetForUpload)

Source from the content-addressed store, hash-verified

113}
114
115func 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
134func shouldRetry(err error) bool {
135 var networkError errNetwork

Callers 2

uploadRunFunction · 0.92
createRunFunction · 0.92

Calls 2

uploadWithDeleteFunction · 0.85
WaitMethod · 0.65

Tested by

no test coverage detected