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

Method oldRequestWithContext

context.go:87–104  ·  view source on GitHub ↗

oldRequestWithContext utilizes inbox and subscription per request.

(ctx context.Context, subj string, hdr, data []byte)

Source from the content-addressed store, hash-verified

85
86// oldRequestWithContext utilizes inbox and subscription per request.
87func (nc *Conn) oldRequestWithContext(ctx context.Context, subj string, hdr, data []byte) (*Msg, error) {
88 inbox := nc.NewInbox()
89 ch := make(chan *Msg, RequestChanLen)
90
91 s, err := nc.subscribe(inbox, _EMPTY_, nil, ch, nil, true, nil)
92 if err != nil {
93 return nil, err
94 }
95 s.AutoUnsubscribe(1)
96 defer s.Unsubscribe()
97
98 err = nc.publish(subj, inbox, false, hdr, data)
99 if err != nil {
100 return nil, err
101 }
102
103 return s.NextMsgWithContext(ctx)
104}
105
106func (s *Subscription) nextMsgWithContext(ctx context.Context, pullSubInternal, waitIfNoMsg bool) (*Msg, error) {
107 if ctx == nil {

Callers 1

requestWithContextMethod · 0.95

Calls 6

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

Tested by

no test coverage detected