chore: add more tests (#3338)

This commit is contained in:
Kevin Wan
2023-06-12 01:22:20 +08:00
committed by GitHub
parent efa6940001
commit f6bdb6e1de
11 changed files with 99 additions and 46 deletions

View File

@@ -42,7 +42,8 @@ func (manager *ResourceManager) Close() error {
}
// GetResource returns the resource associated with given key.
func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error) {
func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (
io.Closer, error) {
val, err := manager.singleFlight.Do(key, func() (any, error) {
manager.lock.RLock()
resource, ok := manager.resources[key]