Skip to content

Commit 13724af

Browse files
authored
gapic: replace CloseIdleConnections with nil setter (#694)
1 parent 4782c38 commit 13724af

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

internal/gengapic/genrest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ func (g *generator) restClientUtilities(serv *descriptor.ServiceDescriptorProto,
149149
p("// Close closes the connection to the API service. The user should invoke this when")
150150
p("// the client is no longer required.")
151151
p("func (c *%s) Close() error {", lowcaseServName)
152-
p(" c.httpClient.CloseIdleConnections()")
152+
p(" // Replace httpClient with nil to force cleanup.")
153+
p(" c.httpClient = nil")
153154
p(" return nil")
154155
p("}")
155156
p("")

internal/gengapic/testdata/deprecated_client_init.want

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ func (c *restClient) setGoogleClientInfo(keyval ...string) {
176176
// Close closes the connection to the API service. The user should invoke this when
177177
// the client is no longer required.
178178
func (c *restClient) Close() error {
179-
c.httpClient.CloseIdleConnections()
179+
// Replace httpClient with nil to force cleanup.
180+
c.httpClient = nil
180181
return nil
181182
}
182183

internal/gengapic/testdata/empty_client_init.want

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ func (c *restClient) setGoogleClientInfo(keyval ...string) {
170170
// Close closes the connection to the API service. The user should invoke this when
171171
// the client is no longer required.
172172
func (c *restClient) Close() error {
173-
c.httpClient.CloseIdleConnections()
173+
// Replace httpClient with nil to force cleanup.
174+
c.httpClient = nil
174175
return nil
175176
}
176177

internal/gengapic/testdata/foo_rest_client_init.want

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ func (c *fooRESTClient) setGoogleClientInfo(keyval ...string) {
114114
// Close closes the connection to the API service. The user should invoke this when
115115
// the client is no longer required.
116116
func (c *fooRESTClient) Close() error {
117-
c.httpClient.CloseIdleConnections()
117+
// Replace httpClient with nil to force cleanup.
118+
c.httpClient = nil
118119
return nil
119120
}
120121

0 commit comments

Comments
 (0)