@@ -73,6 +73,7 @@ type Client struct {
7373 disableRetryInfo bool
7474 retryOption gax.CallOption
7575 executeQueryRetryOption gax.CallOption
76+ enableDirectAccess bool
7677}
7778
7879// ClientConfig has configurations for the client.
@@ -133,6 +134,11 @@ func NewClientWithConfig(ctx context.Context, project, instance string, config C
133134 option .WithGRPCDialOption (grpc .WithDefaultCallOptions (grpc .MaxCallSendMsgSize (1 << 28 ), grpc .MaxCallRecvMsgSize (1 << 28 ))),
134135 )
135136
137+ enableDirectAccess , _ := strconv .ParseBool (os .Getenv ("CBT_ENABLE_DIRECTPATH" ))
138+ if enableDirectAccess {
139+ o = append (o , internaloption .EnableDirectPath (true ), internaloption .EnableDirectPathXds ())
140+ }
141+
136142 // Allow non-default service account in DirectPath.
137143 o = append (o , internaloption .AllowNonDefaultServiceAccount (true ))
138144 o = append (o , opts ... )
@@ -166,6 +172,7 @@ func NewClientWithConfig(ctx context.Context, project, instance string, config C
166172 disableRetryInfo : disableRetryInfo ,
167173 retryOption : retryOption ,
168174 executeQueryRetryOption : executeQueryRetryOption ,
175+ enableDirectAccess : enableDirectAccess ,
169176 }, nil
170177}
171178
@@ -388,6 +395,8 @@ func (c *Client) newFeatureFlags() metadata.MD {
388395 LastScannedRowResponses : true ,
389396 ClientSideMetricsEnabled : c .metricsTracerFactory .enabled ,
390397 RetryInfo : ! c .disableRetryInfo ,
398+ TrafficDirectorEnabled : c .enableDirectAccess ,
399+ DirectAccessRequested : c .enableDirectAccess ,
391400 }
392401
393402 val := ""
0 commit comments