⚠️ Breaking Changes
Factory Signature Changed:
- Old: func() (net.Conn, error)
- New: func(context.Context) (net.Conn, error)
- Why: Allows proper context propagation (timeout/cancellation) and removes internal goroutine overhead.
📦 Migration Guide
// BEFORE
pool, _ := netpool.New(func() (net.Conn, error) {
return net.Dial("tcp", "addr")
}, netpool.WithMaxPool(10))
// AFTER
pool, _ := netpool.New(func(ctx context.Context) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx, "tcp", "addr")
}, netpool.Config{
MaxPool: 10,
})