[GODRIVER-490] Cursor.Next should call getMore in a loop until a document is available Created: 13/Jul/18  Updated: 28/Oct/23  Resolved: 13/Sep/18

Status: Closed
Project: Go Driver
Component/s: CRUD
Affects Version/s: 0.0.9
Fix Version/s: 0.0.14

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Matthew Chiaravalloti
Resolution: Fixed Votes: 0
Labels: newgrad
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by GODRIVER-125 Cursor iteration should complete (abn... Closed
is depended on by GODRIVER-437 Add helpers for database and client l... Closed

 Description   

Fix how tailable cursors work. For context: GODRIVER-125.

In particular, Cursor.Next should return false iff

  • an error occurred
  • the cursorId in the response is 0 and there are no documents left in the current batch of results

Otherwise, it should call the getMore command in a loop until at least one document is returned in the next batch.

Note: this should be done for all cursors, not just tailable. There's nothing in the wire protocol contract that says the server can't return an empty batch with a non-zero cursorId.

Also, consider that the initiating command (e.g. find, aggregate) can return an empty first batch.



 Comments   
Comment by Githook User [ 13/Sep/18 ]

Author:

{'name': 'Matthew Chiaravalloti', 'email': 'matthew.chiaravalloti@mongodb.com', 'username': 'mattChiaravalloti'}

Message: Update Cursor.Next to call getMore in a loop

GODRIVER-490

Change-Id: Id6538bb914a7538781c8270d323efd572033ca3f
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/fdda31272cfc5fe2d9cf5d49e4f46d215daf5268

Generated at Thu Feb 08 08:34:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.