Skip to content

Commit c7b372f

Browse files
committed
GODRIVER-2930 Allow setting batch size for subsequent getMore's on a ChangeStream. (#1342)
1 parent 2a83ff2 commit c7b372f

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
@@ -524,6 +524,16 @@ func (cs *ChangeStream) ID() int64 {
524524
return cs.cursor.ID()
525525
}
526526

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

0 commit comments

Comments
 (0)