Skip to content

Commit 3ff68c3

Browse files
committed
GODRIVER-2930 Allow setting batch size for subsequent getMore's on a ChangeStream. (#1342)
1 parent 730e825 commit 3ff68c3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mongo/change_stream.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,16 @@ func (cs *ChangeStream) ID() int64 {
527527
return cs.cursor.ID()
528528
}
529529

530+
// SetBatchSize sets the number of documents to fetch from the database with
531+
// each iteration of the ChangeStream's "Next" or "TryNext" method. This setting
532+
// only affects subsequent document batches fetched from the database.
533+
func (cs *ChangeStream) SetBatchSize(size int32) {
534+
// Set batch size on the cursor options also so any "resumed" change stream
535+
// cursors will pick up the latest batch size setting.
536+
cs.cursorOptions.BatchSize = size
537+
cs.cursor.SetBatchSize(size)
538+
}
539+
530540
// Decode will unmarshal the current event document into val and return any errors from the unmarshalling process
531541
// without any modification. If val is nil or is a typed nil, an error will be returned.
532542
func (cs *ChangeStream) Decode(val interface{}) error {

0 commit comments

Comments
 (0)