@@ -25,44 +25,34 @@ import (
2525// sessionBuilder is the interface that holds logic of creating sessions.
2626type sessionBuilder func (ctx context.Context ) (* session , error )
2727
28- type nodeChecker interface {
29- HasNode (id uint32 ) bool
30- }
31-
32- type balancer interface {
33- grpc.ClientConnInterface
34- nodeChecker
35- }
36-
37- func New (ctx context.Context , balancer balancer , config * config.Config ) * Client {
28+ func New (ctx context.Context , cc grpc.ClientConnInterface , config * config.Config ) * Client {
3829 onDone := trace .TableOnInit (config .Trace (), & ctx ,
3930 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/3/internal/table.New" ),
4031 )
4132 defer func () {
4233 onDone (config .SizeLimit ())
4334 }()
4435
45- return newClient (ctx , balancer , func (ctx context.Context ) (s * session , err error ) {
46- return newSession (ctx , balancer , config )
36+ return newClient (ctx , cc , func (ctx context.Context ) (s * session , err error ) {
37+ return newSession (ctx , cc , config )
4738 }, config )
4839}
4940
5041func newClient (
5142 ctx context.Context ,
52- balancer balancer ,
43+ cc grpc. ClientConnInterface ,
5344 builder sessionBuilder ,
5445 config * config.Config ,
5546) * Client {
5647 c := & Client {
57- clock : config .Clock (),
58- config : config ,
59- cc : balancer ,
60- nodeChecker : balancer ,
61- build : builder ,
62- index : make (map [* session ]sessionInfo ),
63- idle : list .New (),
64- waitQ : list .New (),
65- limit : config .SizeLimit (),
48+ clock : config .Clock (),
49+ config : config ,
50+ cc : cc ,
51+ build : builder ,
52+ index : make (map [* session ]sessionInfo ),
53+ idle : list .New (),
54+ waitQ : list .New (),
55+ limit : config .SizeLimit (),
6656 waitChPool : sync.Pool {
6757 New : func () interface {} {
6858 ch := make (chan * session )
@@ -84,11 +74,10 @@ func newClient(
8474// A Client is safe for use by multiple goroutines simultaneously.
8575type Client struct {
8676 // read-only fields
87- config * config.Config
88- build sessionBuilder
89- cc grpc.ClientConnInterface
90- nodeChecker nodeChecker
91- clock clockwork.Clock
77+ config * config.Config
78+ build sessionBuilder
79+ cc grpc.ClientConnInterface
80+ clock clockwork.Clock
9281
9382 // read-write fields
9483 mu xsync.Mutex
@@ -404,7 +393,7 @@ func (c *Client) internalPoolGet(ctx context.Context, opts ...getOption) (s *ses
404393 i ++
405394 s = tryGetIdleSession (c )
406395 if s != nil {
407- if ! isValidNode ( c , s ) {
396+ if ! s . isReady ( ) {
408397 closeInvalidSession (ctx , s )
409398 s = nil
410399
@@ -437,11 +426,6 @@ func tryGetIdleSession(c *Client) *session {
437426 return s
438427}
439428
440- //nolint:interfacer
441- func isValidNode (c * Client , s * session ) bool {
442- return c .nodeChecker == nil || c .nodeChecker .HasNode (s .NodeID ())
443- }
444-
445429func closeInvalidSession (ctx context.Context , s * session ) {
446430 _ = s .Close (ctx )
447431}
@@ -599,9 +583,6 @@ func (c *Client) Put(ctx context.Context, s *session) (err error) {
599583 case s .isClosed ():
600584 return xerrors .WithStackTrace (errSessionClosed )
601585
602- case c .nodeChecker != nil && ! c .nodeChecker .HasNode (s .NodeID ()):
603- return xerrors .WithStackTrace (errNodeIsNotObservable )
604-
605586 default :
606587 c .mu .Lock ()
607588 defer c .mu .Unlock ()
0 commit comments