| 303 | } |
| 304 | |
| 305 | func NewPool(auth string, timeout time.Duration) *Pool { |
| 306 | p := &Pool{ |
| 307 | auth: auth, timeout: timeout, |
| 308 | pool: make(map[string]*list.List), |
| 309 | } |
| 310 | p.exit.C = make(chan struct{}) |
| 311 | |
| 312 | if timeout != 0 { |
| 313 | go func() { |
| 314 | var ticker = time.NewTicker(time.Minute) |
| 315 | defer ticker.Stop() |
| 316 | for { |
| 317 | select { |
| 318 | case <-p.exit.C: |
| 319 | return |
| 320 | case <-ticker.C: |
| 321 | p.Cleanup() |
| 322 | } |
| 323 | } |
| 324 | }() |
| 325 | } |
| 326 | |
| 327 | return p |
| 328 | } |
| 329 | |
| 330 | func (p *Pool) isRecyclable(c *Client) bool { |
| 331 | if c.conn.Err() != nil { |