Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(bigtable): attempt DirectPath by default (#3558)
  • Loading branch information
mohanli-ml committed Jan 15, 2021
1 parent e388841 commit 330a3f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bigtable/bigtable.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions bigtable/export_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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))))
}
Expand Down

0 comments on commit 330a3f4

Please sign in to comment.