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

Method Next

jetstream/pull.go:1025–1038  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1023// method will block until the message is retrieved or timeout is
1024// reached.
1025func (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
1040func (s *pullSubscription) pullMessages(subject string) {
1041 for {

Callers

nothing calls this directly

Calls 3

FetchMethod · 0.95
MessagesMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected