()
| 354 | } |
| 355 | |
| 356 | func (p *Pool) Cleanup() error { |
| 357 | p.mu.Lock() |
| 358 | defer p.mu.Unlock() |
| 359 | if p.closed { |
| 360 | return ErrClosedPool |
| 361 | } |
| 362 | |
| 363 | for addr, list := range p.pool { |
| 364 | for i := list.Len(); i != 0; i-- { |
| 365 | c := list.Remove(list.Front()).(*Client) |
| 366 | if p.isRecyclable(c) { |
| 367 | list.PushBack(c) |
| 368 | } else { |
| 369 | c.Close() |
| 370 | } |
| 371 | } |
| 372 | if list.Len() == 0 { |
| 373 | delete(p.pool, addr) |
| 374 | } |
| 375 | } |
| 376 | return nil |
| 377 | } |
| 378 | |
| 379 | func (p *Pool) GetClient(addr string) (*Client, error) { |
| 380 | c, err := p.getClientFromCache(addr) |
no test coverage detected