Stop unsubscribes from the stream and cancels subscription. No more messages will be received after calling this method. All messages that are already in the buffer are discarded.
()
| 209 | // No more messages will be received after calling this method. |
| 210 | // All messages that are already in the buffer are discarded. |
| 211 | func (s *pushSubscription) Stop() { |
| 212 | if !s.closed.CompareAndSwap(false, true) { |
| 213 | return |
| 214 | } |
| 215 | s.Lock() |
| 216 | defer s.Unlock() |
| 217 | close(s.done) |
| 218 | s.subscription.Unsubscribe() |
| 219 | if s.hbMonitor != nil { |
| 220 | s.hbMonitor.Stop() |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // Drain unsubscribes from the stream and cancels subscription. |
| 225 | // All messages that are already in the buffer will be processed in callback function. |
no test coverage detected