Skip to content

Commit

Permalink
http: fix idleConnTimeout not propagated (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaricftw authored and r-hang committed Apr 15, 2020
1 parent cf39dca commit 19799b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- gRPC inbounds correctly convert all YARPC error codes to gRPC error codes,
outside of handler errors. Previously, well-defined YARPC errors were wrapped
with an `Unknown` gRPC code for unimplemented procedures.
- Fixes `idleConnTimeout` not propgated to the underlying http transport.

## [1.44.0] - 2020-02-27
### Added
Expand Down
4 changes: 4 additions & 0 deletions transport/http/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (ts *transportSpec) Spec() yarpcconfig.TransportSpec {
// keepAlive: 30s
// maxIdleConns: 2
// maxIdleConnsPerHost: 2
// idleConnTimeout: 90s
// disableKeepAlives: false
// disableCompression: false
// responseHeaderTimeout: 0s
Expand Down Expand Up @@ -124,6 +125,9 @@ func (ts *transportSpec) buildTransport(tc *TransportConfig, k *yarpcconfig.Kit)
if tc.MaxIdleConnsPerHost > 0 {
options.maxIdleConnsPerHost = tc.MaxIdleConnsPerHost
}
if tc.IdleConnTimeout > 0 {
options.idleConnTimeout = tc.IdleConnTimeout
}
if tc.DisableKeepAlives {
options.disableKeepAlives = true
}
Expand Down
3 changes: 1 addition & 2 deletions transport/http/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,7 @@ func useFakeBuildClient(t *testing.T, want *wantHTTPClient) TransportOption {
assert.Equal(t, want.KeepAlive, options.keepAlive, "http.Client: KeepAlive should match")
assert.Equal(t, want.MaxIdleConns, options.maxIdleConns, "http.Client: MaxIdleConns should match")
assert.Equal(t, want.MaxIdleConnsPerHost, options.maxIdleConnsPerHost, "http.Client: MaxIdleConnsPerHost should match")
// TODO(kris): not sure why the default is not zero.
// assert.Equal(t, want.IdleConnTimeout, options.idleConnTimeout, "http.Client: IdleConnTimeout should match")
assert.Equal(t, want.IdleConnTimeout, options.idleConnTimeout, "http.Client: IdleConnTimeout should match")
assert.Equal(t, want.DisableKeepAlives, options.disableKeepAlives, "http.Client: DisableKeepAlives should match")
assert.Equal(t, want.DisableCompression, options.disableCompression, "http.Client: DisableCompression should match")
assert.Equal(t, want.ResponseHeaderTimeout, options.responseHeaderTimeout, "http.Client: ResponseHeaderTimeout should match")
Expand Down

0 comments on commit 19799b1

Please sign in to comment.