@@ -27,6 +27,7 @@ import (
2727 xtest "github.com/ydb-platform/ydb-go-sdk/v3/pkg/xtest"
2828 "github.com/ydb-platform/ydb-go-sdk/v3/retry"
2929 "github.com/ydb-platform/ydb-go-sdk/v3/testutil"
30+ "github.com/ydb-platform/ydb-go-sdk/v3/trace"
3031)
3132
3233type (
@@ -67,8 +68,13 @@ var defaultTrace = &Trace{
6768 return func (err error ) {
6869 }
6970 },
70- OnGet : func (ctx * context.Context , call stack.Caller ) func (item any , attempts int , err error ) {
71- return func (item any , attempts int , err error ) {
71+ OnGet : func (ctx * context.Context , call stack.Caller ) func (
72+ item any ,
73+ attempts int ,
74+ nodeHintInfo * trace.NodeHintInfo ,
75+ err error ,
76+ ) {
77+ return func (item any , attempts int , nodeHintInfo * trace.NodeHintInfo , err error ) {
7278 }
7379 },
7480 onWait : func () func (item any , err error ) {
@@ -183,6 +189,22 @@ func TestPool(t *testing.T) { //nolint:gocyclo
183189 require .NoError (t , err )
184190 })
185191 t .Run ("RequireNodeIdFromPool" , func (t * testing.T ) {
192+ hintTrace := defaultTrace
193+ var preferredID uint32
194+ var sessionID uint32
195+ hintTrace .OnGet = func (ctx * context.Context , call stack.Caller ) func (
196+ item any ,
197+ attempts int ,
198+ nodeHintInfo * trace.NodeHintInfo ,
199+ err error ,
200+ ) {
201+ return func (item any , attempts int , nodeHintInfo * trace.NodeHintInfo , err error ) {
202+ if nodeHintInfo != nil {
203+ preferredID = nodeHintInfo .PreferredNodeID
204+ sessionID = nodeHintInfo .SessionNodeID
205+ }
206+ }
207+ }
186208 nextNodeID := uint32 (0 )
187209 var newItemCalled uint32
188210 p := New [* testItem , testItem ](rootCtx ,
@@ -201,6 +223,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
201223
202224 return & v , nil
203225 }),
226+ WithLimit [* testItem , testItem ](3 ),
204227 )
205228
206229 item := mustGetItem (t , p )
@@ -262,7 +285,10 @@ func TestPool(t *testing.T) { //nolint:gocyclo
262285 mustPutItem (t , p , item )
263286 mustPutItem (t , p , item2 )
264287 mustPutItem (t , p , item3 )
265-
288+ item , err = p .getItem (endpoint .WithNodeID (context .Background (), 100 ))
289+ require .NoError (t , err )
290+ require .EqualValues (t , 100 , preferredID )
291+ require .EqualValues (t , item .NodeID (), sessionID )
266292 require .EqualValues (t , 3 , newItemCalled )
267293 })
268294 t .Run ("CreateItemOnGivenNode" , func (t * testing.T ) {
@@ -471,7 +497,12 @@ func TestPool(t *testing.T) { //nolint:gocyclo
471497 mustGetItem (t , p )
472498
473499 go func () {
474- p .config .trace .OnGet = func (ctx * context.Context , call stack.Caller ) func (item any , attempts int , err error ) {
500+ p .config .trace .OnGet = func (ctx * context.Context , call stack.Caller ) func (
501+ item any ,
502+ attempts int ,
503+ _ * trace.NodeHintInfo ,
504+ err error ,
505+ ) {
475506 get <- struct {}{}
476507
477508 return nil
0 commit comments