evcc-io/plugin/http_limit.go

21 lines
295 B
Go

package plugin
import "sync"
var (
httpMu sync.Mutex
httpMutexes = map[string]*sync.Mutex{}
)
func muForKey(key string) *sync.Mutex {
httpMu.Lock()
defer httpMu.Unlock()
if mu, ok := httpMutexes[key]; ok {
return mu
}
mu := new(sync.Mutex)
httpMutexes[key] = mu
return mu
}