Repository: googleapis/gapic-generator-go
Pull request #1111 (2022-08-16 21:31:38)

fix: update deprecation warning on Connection methods
Fixes: #1110


Patch:
diff --git a/internal/gengapic/client_init.go b/internal/gengapic/client_init.go
index 25fe949..4e13d36 100644
--- a/internal/gengapic/client_init.go
+++ b/internal/gengapic/client_init.go
@@ -219,7 +219,8 @@ func (g *generator) clientInit(serv *descriptor.ServiceDescriptorProto, servName
 	p("")
 	p("// Connection returns a connection to the API service.")
 	p("//")
-	p("// Deprecated.")
+	p("// Deprecated: Connections are now pooled so this method does not always")
+	p("// return the same resource.")
 	p("func (c *%sClient) Connection() *grpc.ClientConn {", servName)
 	p("  return c.internalClient.Connection()")
 	p("}")
diff --git a/internal/gengapic/gengrpc.go b/internal/gengapic/gengrpc.go
index 83134a2..d261e9c 100644
--- a/internal/gengapic/gengrpc.go
+++ b/internal/gengapic/gengrpc.go
@@ -375,7 +375,8 @@ func (g *generator) grpcClientUtilities(serv *descriptor.ServiceDescriptorProto,
 	// Connection method
 	p("// Connection returns a connection to the API service.")
 	p("//")
-	p("// Deprecated.")
+	p("// Deprecated: Connections are now pooled so this method does not always")
+	p("// return the same resource.")
 	p("func (c *%s) Connection() *grpc.ClientConn {", lowcaseServName)
 	p("  return c.connPool.Conn()")
 	p("}")
diff --git a/internal/gengapic/genrest.go b/internal/gengapic/genrest.go
index 8e2358e..4b86325 100644
--- a/internal/gengapic/genrest.go
+++ b/internal/gengapic/genrest.go
@@ -229,7 +229,7 @@ func (g *generator) restClientUtilities(serv *descriptor.ServiceDescriptorProto,
 
 	p("// Connection returns a connection to the API service.")
 	p("//")
-	p("// Deprecated.")
+	p("// Deprecated: This method always returns nil.")
 	p("func (c *%s) Connection() *grpc.ClientConn {", lowcaseServName)
 	p("    return nil")
 	p("}")


Test patch:
diff --git a/internal/gengapic/testdata/custom_op_init.want b/internal/gengapic/testdata/custom_op_init.want
index 87c49f3..f531aaa 100644
--- a/internal/gengapic/testdata/custom_op_init.want
+++ b/internal/gengapic/testdata/custom_op_init.want
@@ -36,7 +36,8 @@ func (c *Client) setGoogleClientInfo(keyval ...string) {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *Client) Connection() *grpc.ClientConn {
 	return c.internalClient.Connection()
 }
@@ -117,7 +118,7 @@ func (c *restClient) Close() error {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: This method always returns nil.
 func (c *restClient) Connection() *grpc.ClientConn {
 	return nil
 }
diff --git a/internal/gengapic/testdata/deprecated_client_init.want b/internal/gengapic/testdata/deprecated_client_init.want
index 95c25ac..078b833 100644
--- a/internal/gengapic/testdata/deprecated_client_init.want
+++ b/internal/gengapic/testdata/deprecated_client_init.want
@@ -38,7 +38,8 @@ func (c *Client) setGoogleClientInfo(keyval ...string) {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *Client) Connection() *grpc.ClientConn {
 	return c.internalClient.Connection()
 }
@@ -111,7 +112,8 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *gRPCClient) Connection() *grpc.ClientConn {
 	return c.connPool.Conn()
 }
@@ -188,7 +190,7 @@ func (c *restClient) Close() error {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: This method always returns nil.
 func (c *restClient) Connection() *grpc.ClientConn {
 	return nil
 }
diff --git a/internal/gengapic/testdata/empty_client_init.want b/internal/gengapic/testdata/empty_client_init.want
index e25b4d1..b4252ba 100644
--- a/internal/gengapic/testdata/empty_client_init.want
+++ b/internal/gengapic/testdata/empty_client_init.want
@@ -36,7 +36,8 @@ func (c *Client) setGoogleClientInfo(keyval ...string) {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *Client) Connection() *grpc.ClientConn {
 	return c.internalClient.Connection()
 }
@@ -107,7 +108,8 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *gRPCClient) Connection() *grpc.ClientConn {
 	return c.connPool.Conn()
 }
@@ -182,7 +184,7 @@ func (c *restClient) Close() error {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: This method always returns nil.
 func (c *restClient) Connection() *grpc.ClientConn {
 	return nil
 }
diff --git a/internal/gengapic/testdata/foo_client_init.want b/internal/gengapic/testdata/foo_client_init.want
index 5740a4a..f1d45a6 100644
--- a/internal/gengapic/testdata/foo_client_init.want
+++ b/internal/gengapic/testdata/foo_client_init.want
@@ -41,7 +41,8 @@ func (c *FooClient) setGoogleClientInfo(keyval ...string) {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *FooClient) Connection() *grpc.ClientConn {
 	return c.internalClient.Connection()
 }
@@ -138,7 +139,8 @@ func NewFooClient(ctx context.Context, opts ...option.ClientOption) (*FooClient,
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *fooGRPCClient) Connection() *grpc.ClientConn {
 	return c.connPool.Conn()
 }
diff --git a/internal/gengapic/testdata/foo_rest_client_init.want b/internal/gengapic/testdata/foo_rest_client_init.want
index ca0ab80..4db5f91 100644
--- a/internal/gengapic/testdata/foo_rest_client_init.want
+++ b/internal/gengapic/testdata/foo_rest_client_init.want
@@ -41,7 +41,8 @@ func (c *FooClient) setGoogleClientInfo(keyval ...string) {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *FooClient) Connection() *grpc.ClientConn {
 	return c.internalClient.Connection()
 }
@@ -126,7 +127,7 @@ func (c *fooRESTClient) Close() error {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: This method always returns nil.
 func (c *fooRESTClient) Connection() *grpc.ClientConn {
 	return nil
 }
diff --git a/internal/gengapic/testdata/lro_client_init.want b/internal/gengapic/testdata/lro_client_init.want
index 0e28eeb..933d9b1 100644
--- a/internal/gengapic/testdata/lro_client_init.want
+++ b/internal/gengapic/testdata/lro_client_init.want
@@ -47,7 +47,8 @@ func (c *FooClient) setGoogleClientInfo(keyval ...string) {
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *FooClient) Connection() *grpc.ClientConn {
 	return c.internalClient.Connection()
 }
@@ -163,7 +164,8 @@ func NewFooClient(ctx context.Context, opts ...option.ClientOption) (*FooClient,
 
 // Connection returns a connection to the API service.
 //
-// Deprecated.
+// Deprecated: Connections are now pooled so this method does not always
+// return the same resource.
 func (c *fooGRPCClient) Connection() *grpc.ClientConn {
 	return c.connPool.Conn()
 }