Next is used to retrieve the next message from the stream. This method will block until the message is retrieved or timeout is reached.
(opts ...FetchOpt)
| 1023 | // method will block until the message is retrieved or timeout is |
| 1024 | // reached. |
| 1025 | func (p *pullConsumer) Next(opts ...FetchOpt) (Msg, error) { |
| 1026 | res, err := p.Fetch(1, opts...) |
| 1027 | if err != nil { |
| 1028 | return nil, err |
| 1029 | } |
| 1030 | msg := <-res.Messages() |
| 1031 | if msg != nil { |
| 1032 | return msg, nil |
| 1033 | } |
| 1034 | if res.Error() == nil { |
| 1035 | return nil, nats.ErrTimeout |
| 1036 | } |
| 1037 | return nil, res.Error() |
| 1038 | } |
| 1039 | |
| 1040 | func (s *pullSubscription) pullMessages(subject string) { |
| 1041 | for { |