Skip to content

Commit

Permalink
feat(bigtable): add an experimental attempt DirectPath flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanli-ml committed Nov 5, 2020
1 parent 472b731 commit 687595b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bigtable/bigtable.go
Expand Up @@ -19,6 +19,7 @@ package bigtable // import "cloud.google.com/go/bigtable"
import (
"context"
"errors"
"flag"
"fmt"
"io"
"net/url"
Expand All @@ -30,6 +31,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 All @@ -40,6 +42,15 @@ import (

const prodAddr = "bigtable.googleapis.com:443"

// Add an experimental flag to control the attempt to directpath.
// Once e2e tests are finished, this flag will be removed, and client
// will attempt by default.
var attemptDirectPath bool

func init() {
flag.BoolVar(&attemptDirectPath, "it.attempt-directpath", false, "flag to attempt directpath")
}

// 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.
Expand Down Expand Up @@ -79,7 +90,8 @@ 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()),
internaloption.EnableDirectPath(attemptDirectPath))
o = append(o, opts...)
connPool, err := gtransport.DialPool(ctx, o...)
if err != nil {
Expand Down

0 comments on commit 687595b

Please sign in to comment.