[GODRIVER-1374] Add TryNext API Created: 28/Oct/19  Updated: 28/Oct/23  Resolved: 04/Nov/19

Status: Closed
Project: Go Driver
Component/s: CRUD
Affects Version/s: None
Fix Version/s: 1.2.0

Type: Improvement Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

eric.daniels brought up a use case from Stitch for a TryNext API for change streams. When Stitch creates a trigger on a relatively idle collection, Next calls can block for so long that the last seen resume token stored by Stitch falls off the oplog, making it impossible to use the token for restarting the change stream if an unclean shutdown happens.

TryNext should be a non-blocking function that moves the cursor forward and attempts no more than 1 getMore. It should return true if the cursor was iterated successfully and false if the cursor was closed, a getMore attempt resulted in an error, or a getMore attempt returned an empty batch.

david.golden suggested adding some sort of IsAlive function to test if TryNext should be called again after it returns false. We should also make sure to document that this should only be used with tailable cursors. Non-tailable cursors should use Next instead.



 Comments   
Comment by Githook User [ 04/Nov/19 ]

Author:

{'name': 'Divjot Arora', 'username': 'divjotarora', 'email': 'divjot.arora@10gen.com'}

Message: GODRIVER-1374 Add TryNext for cursors and change streams. (#210)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/e4f1e0ae0999a480c617112648d0e8b0e522d6b6

Comment by Divjot Arora (Inactive) [ 30/Oct/19 ]

PR: https://github.com/mongodb/mongo-go-driver/pull/210

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