| 425 | var _ Pooler = (*ConnPool)(nil) |
| 426 | |
| 427 | func NewConnPool(opt *Options) *ConnPool { |
| 428 | p := &ConnPool{ |
| 429 | cfg: opt, |
| 430 | semaphore: internal.NewFastSemaphore(opt.PoolSize), |
| 431 | conns: make(map[uint64]*Conn), |
| 432 | dialsInProgress: make(chan struct{}, opt.MaxConcurrentDials), |
| 433 | dialsQueue: newWantConnQueue(), |
| 434 | idleConns: make([]*Conn, 0, opt.PoolSize), |
| 435 | } |
| 436 | |
| 437 | // Only create MinIdleConns if explicitly requested (> 0) |
| 438 | // This avoids creating connections during pool initialization for tests |
| 439 | if opt.MinIdleConns > 0 { |
| 440 | p.connsMu.Lock() |
| 441 | p.checkMinIdleConns() |
| 442 | p.connsMu.Unlock() |
| 443 | } |
| 444 | |
| 445 | return p |
| 446 | } |
| 447 | |
| 448 | // initializeHooks sets up the pool hooks system. |
| 449 | func (p *ConnPool) initializeHooks() { |