Close closes every connection created by the factory. Connections are closed concurrently.
()
| 88 | // Close closes every connection created by the factory. Connections are closed |
| 89 | // concurrently. |
| 90 | func (f *Factory) Close() { |
| 91 | var wg sync.WaitGroup |
| 92 | f.cache.Range(func(key, value interface{}) bool { |
| 93 | defer f.cache.Delete(key) |
| 94 | |
| 95 | if value.(Pair).Closer == nil { |
| 96 | return true |
| 97 | } |
| 98 | wg.Add(1) |
| 99 | go func(value Pair) { |
| 100 | value.Closer() |
| 101 | wg.Done() |
| 102 | }(value.(Pair)) |
| 103 | return true |
| 104 | }) |
| 105 | wg.Wait() |
| 106 | } |
| 107 | |
| 108 | // CloseConn closes a specific connection in the factory. |
| 109 | func (f *Factory) CloseConn(name string) { |