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

Method Stop

jetstream/pull.go:768–780  ·  view source on GitHub ↗

Stop unsubscribes from the stream and cancels subscription. Calling Next after calling Stop will return ErrMsgIteratorClosed error. All messages that are already in the buffer are discarded.

()

Source from the content-addressed store, hash-verified

766// Next after calling Stop will return ErrMsgIteratorClosed error.
767// All messages that are already in the buffer are discarded.
768func (s *pullSubscription) Stop() {
769 if !s.closed.CompareAndSwap(0, 1) {
770 return
771 }
772 close(s.done)
773 if s.consumeOpts.stopAfterMsgsLeft != nil {
774 if s.delivered >= s.consumeOpts.StopAfter {
775 close(s.consumeOpts.stopAfterMsgsLeft)
776 } else {
777 s.consumeOpts.stopAfterMsgsLeft <- s.consumeOpts.StopAfter - s.delivered
778 }
779 }
780}
781
782// Drain unsubscribes from the stream and cancels subscription. All
783// messages that are already in the buffer will be available on

Callers 2

ConsumeMethod · 0.95
NextMethod · 0.95

Calls 1

CompareAndSwapMethod · 0.80

Tested by

no test coverage detected