@@ -107,20 +107,19 @@ func parseDatabaseName(db string) (project, instance, database string, err error
107107// Client is a client for reading and writing data to a Cloud Spanner database.
108108// A client is safe to use concurrently, except for its Close method.
109109type Client struct {
110- sc * sessionClient
111- idleSessions * sessionPool
112- logger * log.Logger
113- qo QueryOptions
114- ro ReadOptions
115- ao []ApplyOption
116- txo TransactionOptions
117- bwo BatchWriteOptions
118- ct * commonTags
119- disableRouteToLeader bool
120- enableMultiplexedSessionForRW bool
121- dro * sppb.DirectedReadOptions
122- otConfig * openTelemetryConfig
123- metricsTracerFactory * builtinMetricsTracerFactory
110+ sc * sessionClient
111+ idleSessions * sessionPool
112+ logger * log.Logger
113+ qo QueryOptions
114+ ro ReadOptions
115+ ao []ApplyOption
116+ txo TransactionOptions
117+ bwo BatchWriteOptions
118+ ct * commonTags
119+ disableRouteToLeader bool
120+ dro * sppb.DirectedReadOptions
121+ otConfig * openTelemetryConfig
122+ metricsTracerFactory * builtinMetricsTracerFactory
124123}
125124
126125// DatabaseName returns the full name of a database, e.g.,
@@ -548,20 +547,19 @@ func newClientWithConfig(ctx context.Context, database string, config ClientConf
548547 }
549548
550549 c = & Client {
551- sc : sc ,
552- idleSessions : sp ,
553- logger : config .Logger ,
554- qo : getQueryOptions (config .QueryOptions ),
555- ro : config .ReadOptions ,
556- ao : config .ApplyOptions ,
557- txo : config .TransactionOptions ,
558- bwo : config .BatchWriteOptions ,
559- ct : getCommonTags (sc ),
560- disableRouteToLeader : config .DisableRouteToLeader ,
561- dro : config .DirectedReadOptions ,
562- otConfig : otConfig ,
563- metricsTracerFactory : metricsTracerFactory ,
564- enableMultiplexedSessionForRW : config .enableMultiplexedSessionForRW ,
550+ sc : sc ,
551+ idleSessions : sp ,
552+ logger : config .Logger ,
553+ qo : getQueryOptions (config .QueryOptions ),
554+ ro : config .ReadOptions ,
555+ ao : config .ApplyOptions ,
556+ txo : config .TransactionOptions ,
557+ bwo : config .BatchWriteOptions ,
558+ ct : getCommonTags (sc ),
559+ disableRouteToLeader : config .DisableRouteToLeader ,
560+ dro : config .DirectedReadOptions ,
561+ otConfig : otConfig ,
562+ metricsTracerFactory : metricsTracerFactory ,
565563 }
566564 return c , nil
567565}
@@ -1025,7 +1023,7 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
10251023 err error
10261024 )
10271025 if sh == nil || sh .getID () == "" || sh .getClient () == nil {
1028- if c .enableMultiplexedSessionForRW {
1026+ if c .idleSessions . isMultiplexedSessionForRWEnabled () {
10291027 sh , err = c .idleSessions .takeMultiplexed (ctx )
10301028 } else {
10311029 // Session handle hasn't been allocated or has been destroyed.
@@ -1044,7 +1042,7 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
10441042 // Note that the t.begin(ctx) call could change the session that is being used by the transaction, as the
10451043 // BeginTransaction RPC invocation will be retried on a new session if it returns SessionNotFound.
10461044 t .txReadOnly .sh = sh
1047- if err = t .begin (ctx ); err != nil {
1045+ if err = t .begin (ctx , nil ); err != nil {
10481046 trace .TracePrintf (ctx , nil , "Error while BeginTransaction during retrying a ReadWrite transaction: %v" , ToSpannerError (err ))
10491047 return ToSpannerError (err )
10501048 }
@@ -1072,7 +1070,7 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
10721070 return err
10731071 })
10741072 if isUnimplementedErrorForMultiplexedRW (err ) {
1075- c .enableMultiplexedSessionForRW = false
1073+ c .idleSessions . disableMultiplexedSessionForRW ()
10761074 }
10771075 return resp , err
10781076}
0 commit comments