Skip to content

Commit

Permalink
Alias NextMsg to Fetch for Pull Subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarema committed Jun 19, 2021
1 parent cc4f3b2 commit 728bc1e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -3911,7 +3911,14 @@ func (s *Subscription) NextMsg(timeout time.Duration) (*Msg, error) {
if s == nil {
return nil, ErrBadSubscription
}

// In case of Pull Subscription, alias NextMsg to Fetch
if s.typ == PullSubscription {
msgs, err := s.Fetch(1, MaxWait(timeout))
if err != nil {
return nil, err
}
return msgs[0], nil
}
s.mu.Lock()
err := s.validateNextMsgState()
if err != nil {
Expand Down

0 comments on commit 728bc1e

Please sign in to comment.