Skip to content

Commit 0306910

Browse files
authored
feat(bigtable): expose directaccess via a env variable (#12684)
* feat(bigtable): expose directaccess via CBT_ENABLE_DIRECTPATH env * fix: redudanct option * fix
1 parent a330457 commit 0306910

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

bigtable/bigtable.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)