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

Method Next

jetstream/ordered.go:528–541  ·  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. It is not efficient to use Next with on an ordered consumer, as it will reset the consumer for each subsequent Fetch call. Consider using [Consumer.Consume] or [Co

(opts ...FetchOpt)

Source from the content-addressed store, hash-verified

526// reset the consumer for each subsequent Fetch call.
527// Consider using [Consumer.Consume] or [Consumer.Messages] instead.
528func (c *orderedConsumer) Next(opts ...FetchOpt) (Msg, error) {
529 res, err := c.Fetch(1, opts...)
530 if err != nil {
531 return nil, err
532 }
533 msg := <-res.Messages()
534 if msg != nil {
535 return msg, nil
536 }
537 if res.Error() == nil {
538 return nil, nats.ErrTimeout
539 }
540 return nil, res.Error()
541}
542
543func serialNumberFromConsumer(name string) int {
544 if len(name) == 0 {

Callers

nothing calls this directly

Calls 3

FetchMethod · 0.95
MessagesMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected