(addr string)
| 385 | } |
| 386 | |
| 387 | func (p *Pool) getClientFromCache(addr string) (*Client, error) { |
| 388 | p.mu.Lock() |
| 389 | defer p.mu.Unlock() |
| 390 | if p.closed { |
| 391 | return nil, ErrClosedPool |
| 392 | } |
| 393 | if list := p.pool[addr]; list != nil { |
| 394 | for i := list.Len(); i != 0; i-- { |
| 395 | c := list.Remove(list.Front()).(*Client) |
| 396 | if p.isRecyclable(c) { |
| 397 | return c, nil |
| 398 | } else { |
| 399 | c.Close() |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | return nil, nil |
| 404 | } |
| 405 | |
| 406 | func (p *Pool) PutClient(c *Client, err error) { |
| 407 | p.mu.Lock() |
no test coverage detected