@@ -51,6 +51,13 @@ func WithTrace(t trace.DatabaseSQL, opts ...trace.DatabaseSQLComposeOption) Conn
5151 }
5252}
5353
54+ func WithDisableServerBalancer () ConnectorOption {
55+ return func (c * Connector ) error {
56+ c .disableServerBalancer = true
57+ return nil
58+ }
59+ }
60+
5461func Open (d Driver , connection connection , opts ... ConnectorOption ) (_ * Connector , err error ) {
5562 c := & Connector {
5663 driver : d ,
@@ -90,10 +97,11 @@ type Connector struct {
9097 driver Driver
9198 connection connection
9299
93- defaultTxControl * table.TransactionControl
94- defaultQueryMode QueryMode
95- defaultDataQueryOpts []options.ExecuteDataQueryOption
96- defaultScanQueryOpts []options.ExecuteScanQueryOption
100+ defaultTxControl * table.TransactionControl
101+ defaultQueryMode QueryMode
102+ defaultDataQueryOpts []options.ExecuteDataQueryOption
103+ defaultScanQueryOpts []options.ExecuteScanQueryOption
104+ disableServerBalancer bool
97105
98106 trace trace.DatabaseSQL
99107}
@@ -117,11 +125,10 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, err error) {
117125 defer func () {
118126 onDone (err )
119127 }()
120- s , err := c .connection .Table ().CreateSession ( //nolint:staticcheck // SA1019
121- meta .WithAllowFeatures (ctx ,
122- metaHeaders .HintSessionBalancer ,
123- ),
124- )
128+ if ! c .disableServerBalancer {
129+ ctx = meta .WithAllowFeatures (ctx , metaHeaders .HintSessionBalancer )
130+ }
131+ s , err := c .connection .Table ().CreateSession (ctx ) //nolint:staticcheck // SA1019
125132 if err != nil {
126133 return nil , xerrors .WithStackTrace (err )
127134 }
0 commit comments