MCPcopy
hub / github.com/redis/go-redis / NewConnPool

Function NewConnPool

internal/pool/pool.go:427–446  ·  internal/pool/pool.go::NewConnPool
(opt *Options)

Source from the content-addressed store, hash-verified

425var _ Pooler = (*ConnPool)(nil)
426
427func 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.
449func (p *ConnPool) initializeHooks() {

Callers 15

newConnPoolFunction · 0.92
BenchmarkPoolGetPutFunction · 0.92
TestDoubleFreeTurnSimpleFunction · 0.92
BenchmarkPoolGetPutFunction · 0.92
BenchmarkPoolGetRemoveFunction · 0.92
pool_test.goFile · 0.92
TestDoubleFreeTurnBugFunction · 0.85

Calls 3

checkMinIdleConnsMethod · 0.95
NewFastSemaphoreFunction · 0.92
newWantConnQueueFunction · 0.85