@@ -559,11 +559,19 @@ func (c *Client) DoTx(ctx context.Context, op query.TxOperation, opts ...options
559559 return nil
560560}
561561
562- func newPool (
563- ctx context.Context , cfg * config.Config , createSession func (ctx context.Context ) (* Session , error ),
564- ) sessionPool {
565- if cfg .UseSessionPool () {
566- return pool .New (ctx ,
562+ func New (ctx context.Context , balancer grpc.ClientConnInterface , cfg * config.Config ) * Client {
563+ onDone := trace .QueryOnNew (cfg .Trace (), & ctx ,
564+ stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.New" ),
565+ )
566+ defer onDone ()
567+
568+ grpcClient := Ydb_Query_V1 .NewQueryServiceClient (balancer )
569+
570+ client := & Client {
571+ config : cfg ,
572+ queryServiceClient : grpcClient ,
573+ done : make (chan struct {}),
574+ pool : pool .New (ctx ,
567575 pool.WithLimit [* Session , Session ](cfg .PoolLimit ()),
568576 pool.WithTrace [* Session , Session ](poolTrace (cfg .Trace ())),
569577 pool.WithCreateItemTimeout [* Session , Session ](cfg .SessionCreateTimeout ()),
@@ -580,52 +588,14 @@ func newPool(
580588 }
581589 defer cancelCreate ()
582590
583- s , err := createSession (createCtx )
591+ s , err := createSession (createCtx , grpcClient , cfg )
584592 if err != nil {
585593 return nil , xerrors .WithStackTrace (err )
586594 }
587595
588596 return s , nil
589597 }),
590- )
591- }
592-
593- return & poolStub {
594- createSession : createSession ,
595- }
596- }
597-
598- func New (ctx context.Context , balancer grpc.ClientConnInterface , cfg * config.Config ) * Client {
599- onDone := trace .QueryOnNew (cfg .Trace (), & ctx ,
600- stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.New" ),
601- )
602- defer onDone ()
603-
604- grpcClient := Ydb_Query_V1 .NewQueryServiceClient (balancer )
605-
606- client := & Client {
607- config : cfg ,
608- queryServiceClient : grpcClient ,
609- done : make (chan struct {}),
610- pool : newPool (ctx , cfg , func (ctx context.Context ) (_ * Session , err error ) {
611- var (
612- createCtx context.Context
613- cancelCreate context.CancelFunc
614- )
615- if d := cfg .SessionCreateTimeout (); d > 0 {
616- createCtx , cancelCreate = xcontext .WithTimeout (ctx , d )
617- } else {
618- createCtx , cancelCreate = xcontext .WithCancel (ctx )
619- }
620- defer cancelCreate ()
621-
622- s , err := createSession (createCtx , grpcClient , cfg )
623- if err != nil {
624- return nil , xerrors .WithStackTrace (err )
625- }
626-
627- return s , nil
628- }),
598+ ),
629599 }
630600
631601 return client
0 commit comments