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

Method removeSub

nats.go:4977–5013  ·  view source on GitHub ↗

Lock for nc should be held here upon entry

(s *Subscription)

Source from the content-addressed store, hash-verified

4975
4976// Lock for nc should be held here upon entry
4977func (nc *Conn) removeSub(s *Subscription) {
4978 nc.subsMu.Lock()
4979 delete(nc.subs, s.sid)
4980 nc.subsMu.Unlock()
4981 s.mu.Lock()
4982 defer s.mu.Unlock()
4983 // Release callers on NextMsg for SyncSubscription only
4984 if s.mch != nil && s.typ == SyncSubscription {
4985 close(s.mch)
4986 }
4987 s.mch = nil
4988
4989 // If JS subscription then stop HB timer.
4990 if jsi := s.jsi; jsi != nil {
4991 if jsi.hbc != nil {
4992 jsi.hbc.Stop()
4993 jsi.hbc = nil
4994 }
4995 if jsi.csfct != nil {
4996 jsi.csfct.Stop()
4997 jsi.csfct = nil
4998 }
4999 }
5000
5001 if s.typ != AsyncSubscription {
5002 done := s.pDone
5003 if done != nil {
5004 done(s.Subject)
5005 }
5006 }
5007 // Mark as invalid
5008 s.closed = true
5009 s.changeSubStatus(SubscriptionClosed)
5010 if s.pCond != nil {
5011 s.pCond.Broadcast()
5012 }
5013}
5014
5015// SubscriptionType is the type of the Subscription.
5016type SubscriptionType int

Callers 5

waitForMsgsMethod · 0.95
processMsgMethod · 0.95
checkDrainedMethod · 0.95
unsubscribeMethod · 0.95

Calls 2

changeSubStatusMethod · 0.80
StopMethod · 0.65

Tested by

no test coverage detected