func (c *client) waitOnRegion(rpc hrpc.Call, reg hrpc.RegionInfo) (proto.Message, error) { ch := reg.AvailabilityChan() if ch == nil { // WTF, this region is available? Maybe it was marked as such // since waitOnRegion was called. return c.sendRPC(rpc) } // The region is unavailable. Wait for it to become available, // or for the deadline to be exceeded. select { case <-ch: return c.sendRPC(rpc) case <-rpc.Context().Done(): return nil, ErrDeadline } }