in client.go [215:241]
func (c *Connection) waitForResponse(key string, channel chan *status.Status) error {
defer func() {
c.responseMx.Lock()
delete(c.responseSubs, key)
c.responseMx.Unlock()
}()
timer := time.NewTimer(c.timeToWaitForResp)
defer timer.Stop()
select {
case st := <-channel:
if st != nil {
switch st.Code() {
case codes.OK:
case codes.ResourceExhausted:
return fmt.Errorf("%w: %s", ErrResourceExhausted, st.Message())
default:
return fmt.Errorf("unexpected status: %+v", st)
}
}
case <-timer.C:
return fmt.Errorf("%w: timed out waiting for response, MessageID: %q", ErrMessageTimeout, key)
case <-c.closed:
return fmt.Errorf("connection closed with err: %w", c.getCloseErr())
}
return nil
}