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

Function ConcurrentUpload

pkg/cmd/release/shared/upload.go:111–128  ·  view source on GitHub ↗
(httpClient *http.Client, hostname string, uploadURL safeurl.SafeURL, numWorkers int, assets []*AssetForUpload)

Source from the content-addressed store, hash-verified

109}
110
111func 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
130func shouldRetry(err error) bool {
131 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