Skip to content

Commit c337fd4

Browse files
authored
[IMPROVED] Clarify MessagesContext.Next() doc (#1951)
Signed-off-by: Piotr Piotrowski <[email protected]>
1 parent ae3c974 commit c337fd4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

jetstream/pull.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ type (
3333
// MessagesContext supports iterating over a messages on a stream.
3434
// It is returned by [Consumer.Messages] method.
3535
MessagesContext interface {
36-
// Next retrieves next message on a stream. It will block until the next
37-
// message is available. If the context is canceled, Next will return
38-
// ErrMsgIteratorClosed error. An optional timeout or context can be
39-
// provided using NextOpt options. If none are provided, Next will block
40-
// indefinitely until a message is available, iterator is closed or a
41-
// heartbeat error occurs.
36+
// Next retrieves next message on a stream. If MessagesContext is closed
37+
// (either stopped or drained), Next will return ErrMsgIteratorClosed
38+
// error. An optional timeout or context can be provided using NextOpt
39+
// options. If none are provided, Next will block indefinitely until a
40+
// message is available, iterator is closed or a heartbeat error occurs.
4241
Next(opts ...NextOpt) (Msg, error)
4342

4443
// Stop unsubscribes from the stream and cancels subscription. Calling
@@ -589,9 +588,11 @@ var (
589588
errDisconnected = errors.New("disconnected")
590589
)
591590

592-
// Next retrieves next message on a stream. It will block until the next
593-
// message is available. If the context is canceled, Next will return
594-
// ErrMsgIteratorClosed error.
591+
// Next retrieves next message on a stream. If MessagesContext is closed
592+
// (either stopped or drained), Next will return ErrMsgIteratorClosed
593+
// error. An optional timeout or context can be provided using NextOpt
594+
// options. If none are provided, Next will block indefinitely until a
595+
// message is available, iterator is closed or a heartbeat error occurs.
595596
func (s *pullSubscription) Next(opts ...NextOpt) (Msg, error) {
596597
var nextOpts nextOpts
597598
for _, opt := range opts {

0 commit comments

Comments
 (0)