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

Method FetchNoWait

jetstream/ordered.go:501–519  ·  view source on GitHub ↗

FetchNoWait is used to retrieve up to a provided number of messages from a stream. This method will always send a single request and immediately return up to a provided number of messages or wait until at least one message is available or request times out. It is not efficient to use FetchNoWait wi

(batch int)

Source from the content-addressed store, hash-verified

499// reset the consumer for each subsequent Fetch call.
500// Consider using [Consumer.Consume] or [Consumer.Messages] instead.
501func (c *orderedConsumer) FetchNoWait(batch int) (MessageBatch, error) {
502 if c.consumerType == consumerTypeConsume {
503 return nil, ErrOrderConsumerUsedAsConsume
504 }
505 if c.runningFetch != nil && !c.runningFetch.done {
506 return nil, ErrOrderedConsumerConcurrentRequests
507 }
508 c.consumerType = consumerTypeFetch
509 sub := orderedSubscription{
510 consumer: c,
511 done: make(chan struct{}),
512 }
513 c.subscription = &sub
514 err := c.reset()
515 if err != nil {
516 return nil, err
517 }
518 return c.currentConsumer.FetchNoWait(batch)
519}
520
521// Next is used to retrieve the next message from the stream. This
522// method will block until the message is retrieved or timeout is

Callers

nothing calls this directly

Calls 2

resetMethod · 0.95
FetchNoWaitMethod · 0.65

Tested by

no test coverage detected