Skip to content

Commit

Permalink
feat: [inputs/burrow] fill more http transport parameters (#6948)
Browse files Browse the repository at this point in the history
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
  • Loading branch information
funny-falcon and srebhan authored May 19, 2022
1 parent 9a68167 commit 7c89a38
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions plugins/inputs/burrow/burrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package burrow
import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7c89a38

Please sign in to comment.