From 330a3f489e3c534f647549be11f342997243ec3b Mon Sep 17 00:00:00 2001 From: Mohan Li <67390330+mohanli-ml@users.noreply.github.com> Date: Thu, 14 Jan 2021 19:39:44 -0800 Subject: [PATCH] feat(bigtable): attempt DirectPath by default (#3558) --- bigtable/bigtable.go | 4 ++++ bigtable/export_test.go | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bigtable/bigtable.go b/bigtable/bigtable.go index febec4c056f..26384139fba 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" @@ -81,6 +82,9 @@ func NewClientWithConfig(ctx context.Context, project, instance string, config C // 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())) + // Attempts direct access to spanner service over gRPC to improve throughput, + // whether the attempt is allowed is totally controlled by service owner. + o = append(o, internaloption.EnableDirectPath(true)) o = append(o, opts...) connPool, err := gtransport.DialPool(ctx, o...) if err != nil { diff --git a/bigtable/export_test.go b/bigtable/export_test.go index fd84c499585..84ac9608336 100644 --- a/bigtable/export_test.go +++ b/bigtable/export_test.go @@ -28,7 +28,6 @@ import ( btopt "cloud.google.com/go/bigtable/internal/option" "cloud.google.com/go/internal/testutil" "google.golang.org/api/option" - "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" "google.golang.org/grpc" "google.golang.org/grpc/peer" @@ -269,8 +268,6 @@ func (e *ProdEnv) NewClient() (*Client, error) { } if e.config.AttemptDirectPath { - // TODO(mohanli): Move the EnableDirectPath internal option to bigtable.go after e2e tests are done. - clientOpts = append(clientOpts, internaloption.EnableDirectPath(true)) // For DirectPath tests, we need to add an interceptor to check the peer IP. clientOpts = append(clientOpts, option.WithGRPCDialOption(grpc.WithDefaultCallOptions(grpc.Peer(e.peerInfo)))) }