添加一个暂时不用的函数, EnsureTransporterFinalized
This commit is contained in:
parent
3ee03a1c7b
commit
8383a3820f
11
session.go
11
session.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/publicsuffix"
|
"golang.org/x/net/publicsuffix"
|
||||||
|
@ -252,3 +253,13 @@ func (ses *Session) Options(url string) *Workflow {
|
||||||
func (ses *Session) CloseIdleConnections() {
|
func (ses *Session) CloseIdleConnections() {
|
||||||
ses.client.Transport.(*http.Transport).CloseIdleConnections()
|
ses.client.Transport.(*http.Transport).CloseIdleConnections()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnsureTransporterFinalized will ensure that when the HTTP client is GCed
|
||||||
|
// the runtime will close the idle connections (so that they won't leak)
|
||||||
|
// this function was adopted from Hashicorp's go-cleanhttp package
|
||||||
|
// 暂时不用, 标记到以后是否起作用
|
||||||
|
func EnsureTransporterFinalized(httpTransport *http.Transport) {
|
||||||
|
runtime.SetFinalizer(&httpTransport, func(transportInt **http.Transport) {
|
||||||
|
(*transportInt).CloseIdleConnections()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user