feat: [inputs/burrow] fill more http transport parameters (#6948)

Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
This commit is contained in:
Sokolov Yura 2022-05-19 18:10:58 +03:00 committed by GitHub
parent 9a6816782b
commit 7c89a38d11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package burrow
import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"strconv"
@ -168,11 +169,21 @@ func (b *burrow) createClient() (*http.Client, error) {
return nil, err
}
timeout := time.Duration(b.ResponseTimeout)
transport := http.Transport{
DialContext: &net.Dialer{Timeout: timeout, DualStack: true}.DialContext,
TLSClientConfig: tlsCfg,
// If b.ConcurrentConnections <= 1, then DefaultMaxIdleConnsPerHost is used (=2)
MaxIdleConnsPerHost: b.ConcurrentConnections / 2,
// If b.ConcurrentConnections == 0, then it is treated as "no limits"
MaxConnsPerHost: b.ConcurrentConnections,
ResponseHeaderTimeout: timeout,
IdleConnTimeout: 90*time.Second,
}
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsCfg,
},
Timeout: time.Duration(b.ResponseTimeout),
Transport: &transport,
Timeout: timeout,
}
return client, nil