Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ type TransportSettings struct {
// MaxIdleConnsPerHost, default value is `runtime.GOMAXPROCS(0) + 1`.
MaxIdleConnsPerHost int

// MaxConnsPerHost, default value is no limit.
MaxConnsPerHost int

// DisableKeepAlives, default value is `false`.
DisableKeepAlives bool

Expand Down
1 change: 1 addition & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ func TestCustomTransportSettings(t *testing.T) {
ExpectContinueTimeout: 1 * time.Second,
MaxIdleConns: 50,
MaxIdleConnsPerHost: 3,
MaxConnsPerHost: 100,
ResponseHeaderTimeout: 10 * time.Second,
MaxResponseHeaderBytes: 1 << 10,
WriteBufferSize: 2 << 10,
Expand Down
4 changes: 4 additions & 0 deletions resty.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func createTransport(dialer *net.Dialer, transportSettings *TransportSettings) *
t.MaxIdleConnsPerHost = runtime.GOMAXPROCS(0) + 1
}

if transportSettings.MaxConnsPerHost > 0 {
t.MaxConnsPerHost = transportSettings.MaxConnsPerHost
}

//
// No default value in Resty for following settings, added to
// provide ability to set value otherwise the Go HTTP client
Expand Down