Skip to content

Commit e7934c7

Browse files
authored
Apply suggestions from code review
1 parent f209629 commit e7934c7

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

internal/pool/pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type (
6565
Option[PT ItemConstraint[T], T any] func(c *Config[PT, T])
6666
)
6767

68-
func WithCreateItemFunc[PT ItemConstraint[T], T any](f func(context.Context) (PT, error)) Option[PT, T] {
68+
func WithCreateItemFunc[PT ItemConstraint[T], T any](f func(ctx context.Context) (PT, error)) Option[PT, T] {
6969
return func(c *Config[PT, T]) {
7070
c.createItem = f
7171
}
@@ -316,7 +316,7 @@ func (p *Pool[PT, T]) changeState(changeState func() Stats) {
316316
}
317317
}
318318

319-
func (p *Pool[PT, T]) try(ctx context.Context, f func(context.Context, PT) error) (finalErr error) {
319+
func (p *Pool[PT, T]) try(ctx context.Context, f func(ctx context.Context, item PT) error) (finalErr error) {
320320
if onTry := p.config.trace.OnTry; onTry != nil {
321321
onDone := onTry(&ctx,
322322
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/pool.(*Pool).try"),

internal/pool/pool_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
298298
WithItemUsageLimit[*testItem, testItem](5),
299299
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
300300
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
301-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
301+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
302302
atomic.AddInt64(&newCounter, 1)
303303

304304
var v testItem
@@ -322,7 +322,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
322322
var newCounter int64
323323
p := New(rootCtx,
324324
WithLimit[*testItem, testItem](1),
325-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
325+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
326326
atomic.AddInt64(&newCounter, 1)
327327
var v testItem
328328

@@ -356,7 +356,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
356356
WithLimit[*testItem, testItem](3),
357357
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
358358
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
359-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
359+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
360360
var (
361361
idx = created.Add(1) - 1
362362
v = testItem{
@@ -599,7 +599,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
599599
p := New(rootCtx,
600600
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
601601
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
602-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
602+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
603603
atomic.AddInt64(&counter, 1)
604604

605605
if atomic.LoadInt64(&counter) < 10 {
@@ -622,7 +622,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
622622
p := New(rootCtx,
623623
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
624624
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
625-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
625+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
626626
atomic.AddInt64(&counter, 1)
627627

628628
if atomic.LoadInt64(&counter) < 10 {
@@ -646,7 +646,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
646646
p := New(rootCtx,
647647
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
648648
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
649-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
649+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
650650
atomic.AddInt64(&counter, 1)
651651

652652
if atomic.LoadInt64(&counter) < 10 {
@@ -669,7 +669,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
669669
p := New(rootCtx,
670670
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
671671
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
672-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
672+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
673673
atomic.AddInt64(&counter, 1)
674674

675675
if atomic.LoadInt64(&counter) < 10 {
@@ -817,7 +817,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
817817
)
818818
p := New(rootCtx,
819819
WithLimit[*testItem, testItem](1),
820-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
820+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
821821
atomic.AddInt64(&createCounter, 1)
822822

823823
v := &testItem{
@@ -854,7 +854,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
854854
WithLimit[*testItem, testItem](1),
855855
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
856856
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
857-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
857+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
858858
newItems.Add(1)
859859

860860
v := &testItem{
@@ -915,7 +915,7 @@ func TestPool(t *testing.T) { //nolint:gocyclo
915915
WithLimit[*testItem, testItem](1),
916916
WithCreateItemTimeout[*testItem, testItem](50*time.Millisecond),
917917
WithCloseItemTimeout[*testItem, testItem](50*time.Millisecond),
918-
WithCreateItemFunc(func(ctx context.Context) (*testItem, error) {
918+
WithCreateItemFunc(func(context.Context) (*testItem, error) {
919919
created.Add(1)
920920
v := testItem{
921921
v: 0,

0 commit comments

Comments
 (0)