()
| 61 | } |
| 62 | |
| 63 | func (s *Singleton[T]) Close() error { |
| 64 | s.lock.Lock() |
| 65 | defer s.lock.Unlock() |
| 66 | |
| 67 | for key, res := range s.resources { |
| 68 | if err := res.Close(); err != nil { |
| 69 | s.log.Error("resource close failed", err, "key", key) |
| 70 | } |
| 71 | s.log.DebugMsg("resource released", "key", key) |
| 72 | delete(s.resources, key) |
| 73 | } |
| 74 | |
| 75 | return nil |
| 76 | } |