newPool is used to make a new connection pool Maintain at most one connection per host, for up to maxTime. Set maxTime to 0 to disable reaping. maxStreams is used to control the number of idle streams allowed.
(logOutput io.Writer, maxTime time.Duration, maxStreams int)
| 130 | // Set maxTime to 0 to disable reaping. maxStreams is used to control |
| 131 | // the number of idle streams allowed. |
| 132 | func newPool(logOutput io.Writer, maxTime time.Duration, maxStreams int) *connPool { |
| 133 | pool := &connPool{ |
| 134 | logOutput: logOutput, |
| 135 | maxTime: maxTime, |
| 136 | maxStreams: maxStreams, |
| 137 | pool: make(map[string]*conn), |
| 138 | limiter: make(map[string]chan struct{}), |
| 139 | shutdownCh: make(chan struct{}), |
| 140 | } |
| 141 | if maxTime > 0 { |
| 142 | go pool.reap() |
| 143 | } |
| 144 | return pool |
| 145 | } |
| 146 | |
| 147 | // Shutdown is used to close the connection pool |
| 148 | func (p *connPool) Shutdown() error { |