func newPool(config poolConfig, connOpts ...ConnectionOption) (*pool, error) {
	opts := connOpts
	if config.MaxIdleTime != time.Duration(0) {
		opts = append(opts, WithIdleTimeout(func(_ time.Duration) time.Duration { return config.MaxIdleTime }))
	}

	pool := &pool{
		address:   config.Address,
		monitor:   config.PoolMonitor,
		connected: disconnected,
		opened:    make(map[uint64]*connection),
		opts:      opts,
	}

	// we do not pass in config.MaxPoolSize because we manage the max size at this level rather than the resource pool level
	rpc := resourcePoolConfig{
		MinSize:          config.MinPoolSize,
		MaintainInterval: maintainInterval,
		ExpiredFn:        connectionExpiredFunc,
		CloseFn:          connectionCloseFunc,
		InitFn:           pool.connectionInitFunc,
	}

	if pool.monitor != nil {
		pool.monitor.Event(&event.PoolEvent{
			Type: event.PoolCreated,
			PoolOptions: &event.MonitorPoolOptions{
				MaxPoolSize:        config.MaxPoolSize,
				MinPoolSize:        rpc.MinSize,
				WaitQueueTimeoutMS: uint64(config.MaxIdleTime) / uint64(time.Millisecond),
			},
			Address: pool.address.String(),
		})
	}

	rp, err := newResourcePool(rpc)
	if err != nil {
		return nil, err
	}
	pool.conns = rp

	return pool, nil
}
// newPool creates a new pool that will hold size number of idle connections. It will use the
// provided options when creating connections.
newPool creates a new pool that will hold size number of idle connections. It will use the
provided options when creating connections.
// newPool creates a new pool that will hold size number of idle connections . It will use the // provided options when creating connections .
func newPool(config poolConfig, connOpts ...ConnectionOption) (*pool, error) {
	opts := connOpts
	if config.MaxIdleTime != time.Duration(0) {
		opts = append(opts, WithIdleTimeout(func(_ time.Duration) time.Duration { return config.MaxIdleTime }))
	}
	pool := &pool{
		address:   config.Address,
		monitor:   config.PoolMonitor,
		connected: disconnected,
		opened:    make(map[uint64]*connection),
		opts:      opts,
	}
	rpc := resourcePoolConfig{
		MinSize:          config.MinPoolSize,
		MaintainInterval: maintainInterval,
		ExpiredFn:        connectionExpiredFunc,
		CloseFn:          connectionCloseFunc,
		InitFn:           pool.connectionInitFunc,
	}
	if pool.monitor != nil {
		pool.monitor.Event(&event.PoolEvent{
			Type: event.PoolCreated,
			PoolOptions: &event.MonitorPoolOptions{
				MaxPoolSize:        config.MaxPoolSize,
				MinPoolSize:        rpc.MinSize,
				WaitQueueTimeoutMS: uint64(config.MaxIdleTime) / uint64(time.Millisecond),
			},
			Address: pool.address.String(),
		})
	}
	rp, err := newResourcePool(rpc)
	if err != nil {
		return nil, err
	}
	pool.conns = rp
	return pool, nil
}
func newPool ( config poolConfig , connOpts ... ConnectionOption ) ( * pool , error ) { opts := connOpts if config . MaxIdleTime != time . Duration ( 0 ) { opts = append ( opts , WithIdleTimeout ( func ( _ time . Duration ) time . Duration { return config . MaxIdleTime } ) ) } pool := & pool { address : config . Address , monitor : config . PoolMonitor , connected : disconnected , opened : make ( map [ uint64 ] * connection ) , opts : opts , } rpc := resourcePoolConfig { MinSize : config . MinPoolSize , MaintainInterval : maintainInterval , ExpiredFn : connectionExpiredFunc , CloseFn : connectionCloseFunc , InitFn : pool . connectionInitFunc , } if pool . monitor != nil { pool . monitor . Event ( & event . PoolEvent { Type : event . PoolCreated , PoolOptions : & event . MonitorPoolOptions { MaxPoolSize : config . MaxPoolSize , MinPoolSize : rpc . MinSize , WaitQueueTimeoutMS : uint64 ( config . MaxIdleTime ) / uint64 ( time . Millisecond ) , } , Address : pool . address . String ( ) , } ) } rp , err := newResourcePool ( rpc ) if err != nil { return nil , err } pool . conns = rp return pool , nil }
newPool creates a new pool that will hold size number of idle connections.
newPool creates a new pool that will hold size number of idle connections .
// we do not pass in config.MaxPoolSize because we manage the max size at this level rather than the resource pool level