hostLock returns a per-host mutex so that only requests for the same host block each other during migration/pool creation, not all hosts.
(key string)
| 47 | // hostLock returns a per-host mutex so that only requests for the same host |
| 48 | // block each other during migration/pool creation, not all hosts. |
| 49 | func (c *PoolCache) hostLock(key string) *sync.Mutex { |
| 50 | v, _ := c.hostMu.LoadOrStore(key, &sync.Mutex{}) |
| 51 | return v.(*sync.Mutex) |
| 52 | } |
| 53 | |
| 54 | // GetOrCreate returns the database for the given host, creating it on first access. |
| 55 | // Runs migrations before creating the pool. Returns nil if the host is not found or suspended. |