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

Method AutoUnsubscribe

nats.go:5267–5279  ·  view source on GitHub ↗

AutoUnsubscribe will issue an automatic Unsubscribe that is processed by the server when max messages have been received. This can be useful when sending a request to an unknown number of subscribers.

(max int)

Source from the content-addressed store, hash-verified

5265// This can be useful when sending a request to an unknown number
5266// of subscribers.
5267func (s *Subscription) AutoUnsubscribe(max int) error {
5268 if s == nil {
5269 return ErrBadSubscription
5270 }
5271 s.mu.Lock()
5272 conn := s.conn
5273 closed := s.closed
5274 s.mu.Unlock()
5275 if conn == nil || closed {
5276 return ErrBadSubscription
5277 }
5278 return conn.unsubscribe(s, max, false)
5279}
5280
5281// SetClosedHandler will set the closed handler for when a subscription
5282// is closed (either unsubscribed or drained).

Callers 15

TestNilConnectionFunction · 0.95
oldRequestMethod · 0.80
oldRequestWithContextMethod · 0.80
TestBarrierFunction · 0.80
TestServerAutoUnsubFunction · 0.80
TestClientSyncAutoUnsubFunction · 0.80
TestClientChanAutoUnsubFunction · 0.80
TestClientASyncAutoUnsubFunction · 0.80

Calls 1

unsubscribeMethod · 0.80