Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added connection keep feature. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ func (t *Transport) QueueForIdleConnForTesting() {
}

// PutIdleTestConn reports whether it was able to insert a fresh
// persistConn for scheme, addr into the idle connection pool.
// PersistConn for scheme, addr into the idle connection pool.
func (t *Transport) PutIdleTestConn(scheme, addr string) bool {
c, _ := net.Pipe()
key := connectMethodKey{"", scheme, addr, false}

if t.MaxConnsPerHost > 0 {
// Transport is tracking conns-per-host.
// Increment connection count to account
// for new persistConn created below.
// for new PersistConn created below.
t.connsPerHostMu.Lock()
if t.connsPerHost == nil {
t.connsPerHost = make(map[connectMethodKey]int)
Expand All @@ -206,7 +206,7 @@ func (t *Transport) PutIdleTestConn(scheme, addr string) bool {
t.connsPerHostMu.Unlock()
}

return t.tryPutIdleConn(&persistConn{
return t.tryPutIdleConn(&PersistConn{
t: t,
conn: c, // dummy
closech: make(chan struct{}), // so it can be closed
Expand All @@ -215,14 +215,14 @@ func (t *Transport) PutIdleTestConn(scheme, addr string) bool {
}

// PutIdleTestConnH2 reports whether it was able to insert a fresh
// HTTP/2 persistConn for scheme, addr into the idle connection pool.
// HTTP/2 PersistConn for scheme, addr into the idle connection pool.
func (t *Transport) PutIdleTestConnH2(scheme, addr string, alt RoundTripper) bool {
key := connectMethodKey{"", scheme, addr, false}

if t.MaxConnsPerHost > 0 {
// Transport is tracking conns-per-host.
// Increment connection count to account
// for new persistConn created below.
// for new PersistConn created below.
t.connsPerHostMu.Lock()
if t.connsPerHost == nil {
t.connsPerHost = make(map[connectMethodKey]int)
Expand All @@ -231,7 +231,7 @@ func (t *Transport) PutIdleTestConnH2(scheme, addr string, alt RoundTripper) boo
t.connsPerHostMu.Unlock()
}

return t.tryPutIdleConn(&persistConn{
return t.tryPutIdleConn(&PersistConn{
t: t,
alt: alt,
cacheKey: key,
Expand Down
Loading