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

Method oldRequest

nats.go:4688–4705  ·  view source on GitHub ↗

oldRequest will create an Inbox and perform a Request() call with the Inbox reply and return the first reply received. This is optimized for the case of multiple responses.

(subj string, hdr, data []byte, timeout time.Duration)

Source from the content-addressed store, hash-verified

4686// with the Inbox reply and return the first reply received.
4687// This is optimized for the case of multiple responses.
4688func (nc *Conn) oldRequest(subj string, hdr, data []byte, timeout time.Duration) (*Msg, error) {
4689 inbox := nc.NewInbox()
4690 ch := make(chan *Msg, RequestChanLen)
4691
4692 s, err := nc.subscribe(inbox, _EMPTY_, nil, ch, nil, true, nil)
4693 if err != nil {
4694 return nil, err
4695 }
4696 s.AutoUnsubscribe(1)
4697 defer s.Unsubscribe()
4698
4699 err = nc.publish(subj, inbox, false, hdr, data)
4700 if err != nil {
4701 return nil, err
4702 }
4703
4704 return s.NextMsg(timeout)
4705}
4706
4707// InboxPrefix is the prefix for all inbox subjects.
4708const (

Callers 1

requestMethod · 0.95

Calls 6

NewInboxMethod · 0.95
subscribeMethod · 0.95
publishMethod · 0.95
AutoUnsubscribeMethod · 0.80
UnsubscribeMethod · 0.80
NextMsgMethod · 0.80

Tested by

no test coverage detected