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.
()
| 766 | // Next after calling Stop will return ErrMsgIteratorClosed error. |
| 767 | // All messages that are already in the buffer are discarded. |
| 768 | func (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 |
no test coverage detected