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

Method SetPendingLimits

nats.go:5665–5682  ·  view source on GitHub ↗

SetPendingLimits sets the limits for pending msgs and bytes for this subscription. Zero is not allowed. Any negative value means that the given metric is not limited.

(msgLimit, bytesLimit int)

Source from the content-addressed store, hash-verified

5663// SetPendingLimits sets the limits for pending msgs and bytes for this subscription.
5664// Zero is not allowed. Any negative value means that the given metric is not limited.
5665func (s *Subscription) SetPendingLimits(msgLimit, bytesLimit int) error {
5666 if s == nil {
5667 return ErrBadSubscription
5668 }
5669 s.mu.Lock()
5670 defer s.mu.Unlock()
5671 if s.conn == nil || s.closed {
5672 return ErrBadSubscription
5673 }
5674 if s.typ == ChanSubscription {
5675 return ErrTypeSubscription
5676 }
5677 if msgLimit == 0 || bytesLimit == 0 {
5678 return ErrInvalidArg
5679 }
5680 s.pMsgsLimit, s.pBytesLimit = msgLimit, bytesLimit
5681 return nil
5682}
5683
5684// Delivered returns the number of delivered messages for this subscription.
5685func (s *Subscription) Delivered() (int64, error) {

Callers 15

TestCallbacksOrderFunction · 0.95
TestSetPendingLimitsFunction · 0.95
TestNilConnectionFunction · 0.95
addEndpointFunction · 0.95
subscribeMethod · 0.80
TestWSStressFunction · 0.80
TestSlowSubscriberFunction · 0.80
TestSlowChanSubscriberFunction · 0.80
TestSlowAsyncSubscriberFunction · 0.80

Calls

no outgoing calls

Tested by 14

TestCallbacksOrderFunction · 0.76
TestSetPendingLimitsFunction · 0.76
TestNilConnectionFunction · 0.76
TestWSStressFunction · 0.64
TestSlowSubscriberFunction · 0.64
TestSlowChanSubscriberFunction · 0.64
TestSlowAsyncSubscriberFunction · 0.64
TestAsyncErrHandlerFunction · 0.64
TestSubscriptionTypesFunction · 0.64