mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
performance: tune shared HTTP transport for concurrent CDN downloads
This commit is contained in:
@@ -31,18 +31,20 @@ type Downloader struct {
|
||||
barStarted atomic.Int32
|
||||
}
|
||||
|
||||
const downloadBufferSize = 1 << 20
|
||||
|
||||
func New() *Downloader {
|
||||
return NewWithOptions(true, true)
|
||||
return NewWithOptions(true, true, 0)
|
||||
}
|
||||
|
||||
func NewWithVerifySSL(verifySSL bool) *Downloader {
|
||||
return NewWithOptions(verifySSL, true)
|
||||
return NewWithOptions(verifySSL, true, 0)
|
||||
}
|
||||
|
||||
func NewWithOptions(verifySSL bool, showProgress bool) *Downloader {
|
||||
func NewWithOptions(verifySSL bool, showProgress bool, maxConnsPerHost int) *Downloader {
|
||||
forceProgress := strings.EqualFold(os.Getenv("STREAMRIP_GO_FORCE_PROGRESS"), "1") || strings.EqualFold(os.Getenv("STREAMRIP_GO_FORCE_PROGRESS"), "true")
|
||||
interactive := showProgress && (forceProgress || (term.IsTerminal(int(os.Stderr.Fd())) && strings.ToLower(os.Getenv("TERM")) != "dumb"))
|
||||
d := &Downloader{http: netutil.NewHTTPClient(0, verifySSL), showProgress: interactive}
|
||||
d := &Downloader{http: netutil.NewHTTPClient(0, verifySSL, maxConnsPerHost), showProgress: interactive}
|
||||
if interactive {
|
||||
d.progress = mpb.New(mpb.WithWidth(40), mpb.WithOutput(os.Stderr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user