Default HTTP keep-alive ON for remote read/write
This commit is contained in:
parent
e0a4d18301
commit
9d6b945e41
|
@ -526,7 +526,7 @@ type HTTPClientConfig struct {
|
|||
ProxyURL URL `yaml:"proxy_url,omitempty"`
|
||||
// TLSConfig to use to connect to the targets.
|
||||
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
|
||||
// If set, override whether to use HTTP KeepAlive - defaults OFF
|
||||
// If set, override whether to use HTTP KeepAlive - scraping defaults OFF, remote read/write defaults ON
|
||||
KeepAlive *bool `yaml:"keep_alive,omitempty"`
|
||||
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
|
|
|
@ -51,6 +51,11 @@ type clientConfig struct {
|
|||
|
||||
// NewClient creates a new Client.
|
||||
func NewClient(index int, conf *clientConfig) (*Client, error) {
|
||||
// If not specified in config, allow HTTP connections for remote API to use keep-alive
|
||||
if conf.httpClientConfig.KeepAlive == nil {
|
||||
val := true
|
||||
conf.httpClientConfig.KeepAlive = &val
|
||||
}
|
||||
httpClient, err := httputil.NewClientFromConfig(conf.httpClientConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue