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

Method Drain

nats.go:5066–5077  ·  view source on GitHub ↗

Drain will remove interest but continue callbacks until all messages have been processed. For a JetStream subscription, if the library has created the JetStream consumer, the library will send a DeleteConsumer request to the server when the drain operation completes. If a failure occurs when deleti

()

Source from the content-addressed store, hash-verified

5064// ensure that the consumer is not created by the library, which means
5065// create the consumer with AddConsumer and bind to this consumer.
5066func (s *Subscription) Drain() error {
5067 if s == nil {
5068 return ErrBadSubscription
5069 }
5070 s.mu.Lock()
5071 conn := s.conn
5072 s.mu.Unlock()
5073 if conn == nil {
5074 return ErrBadSubscription
5075 }
5076 return conn.unsubscribe(s, 0, true)
5077}
5078
5079// IsDraining returns a boolean indicating whether the subscription
5080// is being drained.

Callers

nothing calls this directly

Calls 1

unsubscribeMethod · 0.80

Tested by

no test coverage detected