diff --git a/bigtable/bigtable.go b/bigtable/bigtable.go index 594c0d2c0340..38325af1f2da 100644 --- a/bigtable/bigtable.go +++ b/bigtable/bigtable.go @@ -30,6 +30,7 @@ import ( "github.com/golang/protobuf/proto" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" btpb "google.golang.org/genproto/googleapis/bigtable/v2" "google.golang.org/grpc" @@ -38,8 +39,10 @@ import ( "google.golang.org/grpc/status" ) -const prodAddr = "bigtable.googleapis.com:443" - +const ( + prodAddr = "bigtable.googleapis.com:443" + attemptDirectPath = true +) // Client is a client for reading and writing data to tables in an instance. // // A Client is safe to use concurrently, except for its Close method. @@ -79,7 +82,9 @@ func NewClientWithConfig(ctx context.Context, project, instance string, config C option.WithGRPCDialOption(grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(1<<28), grpc.MaxCallRecvMsgSize(1<<28))), // TODO(grpc/grpc-go#1388) using connection pool without WithBlock // can cause RPCs to fail randomly. We can delete this after the issue is fixed. - option.WithGRPCDialOption(grpc.WithBlock())) + option.WithGRPCDialOption(grpc.WithBlock()), + // Attempt DirectPath by default + internaloption.EnableDirectPath(attemptDirectPath)) o = append(o, opts...) connPool, err := gtransport.DialPool(ctx, o...) if err != nil {