File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ type Client interface {
79
79
Do (context.Context , * http.Request ) (* http.Response , []byte , error )
80
80
}
81
81
82
+ type closeIdler interface {
83
+ CloseIdleConnections ()
84
+ }
85
+
82
86
// NewClient returns a new Client.
83
87
//
84
88
// It is safe to use the returned Client from multiple goroutines.
@@ -99,6 +103,10 @@ func NewClient(cfg Config) (Client, error) {
99
103
}, nil
100
104
}
101
105
106
+ func ClientCloseIdler (cl Client ) {
107
+ cl .(closeIdler ).CloseIdleConnections ()
108
+ }
109
+
102
110
type httpClient struct {
103
111
endpoint * url.URL
104
112
client http.Client
@@ -118,6 +126,10 @@ func (c *httpClient) URL(ep string, args map[string]string) *url.URL {
118
126
return & u
119
127
}
120
128
129
+ func (c * httpClient ) CloseIdleConnections () {
130
+ c .client .CloseIdleConnections ()
131
+ }
132
+
121
133
func (c * httpClient ) Do (ctx context.Context , req * http.Request ) (* http.Response , []byte , error ) {
122
134
if ctx != nil {
123
135
req = req .WithContext (ctx )
You can’t perform that action at this time.
0 commit comments