transport/grpc: WithGRPCConnectionPool is a no-op for some APIs

Connection pooling is now done via transport/grpc.DialPool and is no
longer supported with transport/grpc.Dial.

See https://github.com/googleapis/google-cloud-go/issues/1777 for
the list of packages that will no longer support gRPC connection
pooling after this change is merged.

Fixes https://github.com/googleapis/google-api-go-client/issues/441

Change-Id: I8e05af53940d6e0af3c2acce9f81b49eaa78bd54
Reviewed-on: https://code-review.googlesource.com/c/google-api-go-client/+/50573
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Cody Oss <codyoss@google.com>
diff --git a/internal/pool.go b/internal/pool.go
deleted file mode 100644
index 908579f..0000000
--- a/internal/pool.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2016 Google LLC.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package internal
-
-import (
-	"errors"
-
-	"google.golang.org/grpc/naming"
-)
-
-// TODO: move to transport/grpc package
-
-// PoolResolver provides a fixed list of addresses to load balance between
-// and does not provide further updates.
-type PoolResolver struct {
-	poolSize int
-	dialOpt  *DialSettings
-	ch       chan []*naming.Update
-}
-
-// NewPoolResolver returns a PoolResolver
-// This is an EXPERIMENTAL API and may be changed or removed in the future.
-func NewPoolResolver(size int, o *DialSettings) *PoolResolver {
-	return &PoolResolver{poolSize: size, dialOpt: o}
-}
-
-// Resolve returns a Watcher for the endpoint defined by the DialSettings
-// provided to NewPoolResolver.
-func (r *PoolResolver) Resolve(target string) (naming.Watcher, error) {
-	if r.dialOpt.Endpoint == "" {
-		return nil, errors.New("no endpoint configured")
-	}
-	addrs := make([]*naming.Update, 0, r.poolSize)
-	for i := 0; i < r.poolSize; i++ {
-		addrs = append(addrs, &naming.Update{Op: naming.Add, Addr: r.dialOpt.Endpoint, Metadata: i})
-	}
-	r.ch = make(chan []*naming.Update, 1)
-	r.ch <- addrs
-	return r, nil
-}
-
-// Next returns a static list of updates on the first call,
-// and blocks indefinitely until Close is called on subsequent calls.
-func (r *PoolResolver) Next() ([]*naming.Update, error) {
-	return <-r.ch, nil
-}
-
-// Close releases resources associated with the pool and causes Next to unblock.
-func (r *PoolResolver) Close() {
-	close(r.ch)
-}
diff --git a/internal/pool_test.go b/internal/pool_test.go
deleted file mode 100644
index 39fa2f0..0000000
--- a/internal/pool_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2016 Google LLC.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package internal
-
-import (
-	"testing"
-	"time"
-
-	"google.golang.org/grpc/naming"
-)
-
-func TestConnectionPool(t *testing.T) {
-	addr := "127.0.0.1:123"
-	ds := DialSettings{Endpoint: addr}
-	pr := NewPoolResolver(4, &ds)
-	watcher, err := pr.Resolve(addr)
-	if err != nil {
-		t.Fatalf("Resolve: %v", err)
-	}
-
-	updates, err := watcher.Next()
-	if err != nil {
-		t.Fatalf("Next: %v", err)
-	}
-	if len(updates) != 4 {
-		t.Fatalf("Update count: %v", err)
-	}
-	metaSeen := make(map[interface{}]bool)
-	for _, u := range updates {
-		if u.Addr != addr {
-			t.Errorf("Addr from update: wanted %v, got %v", addr, u.Addr)
-		}
-		// Metadata must be unique
-		if metaSeen[u.Metadata] {
-			t.Errorf("Wanted %v to be unique, got %v", u.Metadata, metaSeen)
-		}
-		metaSeen[u.Metadata] = true
-	}
-
-	// Test that Next blocks until Close and returns nil.
-	nextc := make(chan []*naming.Update)
-	go func() {
-		next, err := watcher.Next()
-		if err != nil {
-			t.Errorf("Next: expected success, got %v", err)
-		}
-		nextc <- next
-	}()
-	time.Sleep(50 * time.Millisecond) // wait for watcher.Next goroutine
-	select {
-	case <-nextc:
-		t.Fatal("next should not have been called yet")
-	default:
-	}
-	watcher.Close()
-	select {
-	case next := <-nextc:
-		if next != nil {
-			t.Errorf("Next: expected nil, got %v", next)
-		}
-	case <-time.After(50 * time.Millisecond):
-		t.Error("Next: did not return after 100ms")
-	}
-}
diff --git a/option/option.go b/option/option.go
index 5fd1e4c..b7c40d6 100644
--- a/option/option.go
+++ b/option/option.go
@@ -143,6 +143,7 @@
 
 // WithGRPCConnectionPool returns a ClientOption that creates a pool of gRPC
 // connections that requests will be balanced between.
+//
 // This is an EXPERIMENTAL API and may be changed or removed in the future.
 func WithGRPCConnectionPool(size int) ClientOption {
 	return withGRPCConnectionPool(size)
diff --git a/transport/grpc/dial.go b/transport/grpc/dial.go
index e5adc37..0131a2c 100644
--- a/transport/grpc/dial.go
+++ b/transport/grpc/dial.go
@@ -43,11 +43,10 @@
 	if o.GRPCConnPool != nil {
 		return o.GRPCConnPool.Conn(), nil
 	}
-	if o.GRPCConnPoolSize != 0 {
-		// NOTE(cbro): RoundRobin and WithBalancer are deprecated and we need to remove usages of it.
-		balancer := grpc.RoundRobin(internal.NewPoolResolver(o.GRPCConnPoolSize, o))
-		o.GRPCDialOpts = append(o.GRPCDialOpts, grpc.WithBalancer(balancer))
-	}
+	// NOTE(cbro): We removed support for option.WithGRPCConnPool (GRPCConnPoolSize)
+	// on 2020-02-12 because RoundRobin and WithBalancer are deprecated and we need to remove usages of it.
+	//
+	// Connection pooling is only done via DialPool.
 	return dial(ctx, false, o)
 }