MCPcopy
hub / github.com/nats-io/nats.go / request

Method request

nats.go:4637–4656  ·  view source on GitHub ↗
(subj string, hdr, data []byte, timeout time.Duration)

Source from the content-addressed store, hash-verified

4635}
4636
4637func (nc *Conn) request(subj string, hdr, data []byte, timeout time.Duration) (*Msg, error) {
4638 if nc == nil {
4639 return nil, ErrInvalidConnection
4640 }
4641
4642 var m *Msg
4643 var err error
4644
4645 if nc.useOldRequestStyle() {
4646 m, err = nc.oldRequest(subj, hdr, data, timeout)
4647 } else {
4648 m, err = nc.newRequest(subj, hdr, data, timeout)
4649 }
4650
4651 // Check for no responder status.
4652 if err == nil && len(m.Data) == 0 && m.Header.Get(statusHdr) == noResponders {
4653 m, err = nil, ErrNoResponders
4654 }
4655 return m, err
4656}
4657
4658func (nc *Conn) newRequest(subj string, hdr, data []byte, timeout time.Duration) (*Msg, error) {
4659 mch, token, err := nc.createNewRequestAndSend(subj, hdr, data)

Callers 2

RequestMsgMethod · 0.95
RequestMethod · 0.95

Calls 4

useOldRequestStyleMethod · 0.95
oldRequestMethod · 0.95
newRequestMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected