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

Method RequestMsg

nats.go:4612–4622  ·  view source on GitHub ↗

RequestMsg will send a request payload including optional headers and deliver the response message, or an error, including a timeout if no message was received properly.

(msg *Msg, timeout time.Duration)

Source from the content-addressed store, hash-verified

4610// RequestMsg will send a request payload including optional headers and deliver
4611// the response message, or an error, including a timeout if no message was received properly.
4612func (nc *Conn) RequestMsg(msg *Msg, timeout time.Duration) (*Msg, error) {
4613 if msg == nil {
4614 return nil, ErrInvalidMsg
4615 }
4616 hdr, err := msg.headerBytes()
4617 if err != nil {
4618 return nil, err
4619 }
4620
4621 return nc.request(msg.Subject, hdr, msg.Data, timeout)
4622}
4623
4624// Request will send a request payload and deliver the response message,
4625// or an error, including a timeout if no message was received properly.

Callers 6

PublishMsgMethod · 0.80
TestRequestMsgFunction · 0.80
TestNoHeaderSupportFunction · 0.80
TestRequestRespondFunction · 0.80

Calls 2

requestMethod · 0.95
headerBytesMethod · 0.80

Tested by 5

TestRequestMsgFunction · 0.64
TestNoHeaderSupportFunction · 0.64
TestRequestRespondFunction · 0.64