Close closes all FreeLists in the pool.
()
| 193 | |
| 194 | // Close closes all FreeLists in the pool. |
| 195 | func (p *ClientPool) Close() error { |
| 196 | var errmsgs []string |
| 197 | p.nodeFreeLists.Range(func(k, v interface{}) bool { |
| 198 | if err := v.(*freelist).close(); err != nil { |
| 199 | errmsgs = append(errmsgs, err.Error()) |
| 200 | } |
| 201 | return true |
| 202 | }) |
| 203 | if len(errmsgs) > 0 { |
| 204 | return errors.Wrap(errors.New(strings.Join(errmsgs, ", ")), "close connection pool") |
| 205 | } |
| 206 | return nil |
| 207 | } |
| 208 | |
| 209 | // Len returns the connection count in the pool. |
| 210 | func (p *ClientPool) Len() (total int) { |