oldRequestWithContext utilizes inbox and subscription per request.
(ctx context.Context, subj string, hdr, data []byte)
| 85 | |
| 86 | // oldRequestWithContext utilizes inbox and subscription per request. |
| 87 | func (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 | |
| 106 | func (s *Subscription) nextMsgWithContext(ctx context.Context, pullSubInternal, waitIfNoMsg bool) (*Msg, error) { |
| 107 | if ctx == nil { |
no test coverage detected