(subj string, hdr, data []byte, timeout time.Duration)
| 4656 | } |
| 4657 | |
| 4658 | func (nc *Conn) newRequest(subj string, hdr, data []byte, timeout time.Duration) (*Msg, error) { |
| 4659 | mch, token, err := nc.createNewRequestAndSend(subj, hdr, data) |
| 4660 | if err != nil { |
| 4661 | return nil, err |
| 4662 | } |
| 4663 | |
| 4664 | t := globalTimerPool.Get(timeout) |
| 4665 | defer globalTimerPool.Put(t) |
| 4666 | |
| 4667 | var ok bool |
| 4668 | var msg *Msg |
| 4669 | |
| 4670 | select { |
| 4671 | case msg, ok = <-mch: |
| 4672 | if !ok { |
| 4673 | return nil, ErrConnectionClosed |
| 4674 | } |
| 4675 | case <-t.C: |
| 4676 | nc.mu.Lock() |
| 4677 | delete(nc.respMap, token) |
| 4678 | nc.mu.Unlock() |
| 4679 | return nil, ErrTimeout |
| 4680 | } |
| 4681 | |
| 4682 | return msg, nil |
| 4683 | } |
| 4684 | |
| 4685 | // oldRequest will create an Inbox and perform a Request() call |
| 4686 | // with the Inbox reply and return the first reply received. |
no test coverage detected