[GODRIVER-2759] Return an error if a "ChangeStream" is invalidated Created: 14/Feb/23  Updated: 08/Jan/24

Status: Backlog
Project: Go Driver
Component/s: Change Streams
Affects Version/s: None
Fix Version/s: 2.0.0

Type: Improvement Priority: Unknown
Reporter: Matt Dale Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Epic Link: Go Driver 2.0: Driver
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Currently, if users are iterating a ChangeStream, they have to check both stop conditions Err() != nil (i.e. "there was an error") and if ID() == 0 (i.e. "the server invalidated the cursor"). For example:

for {
	if c.TryNext(...) {
		// Use the result.
	}
	if c.Err() != nil {
		panic(c.Err())
	}
	if c.ID() == 0 {
		break
	}
}

A more obvious pattern is to return an error if the server invalidates the cursor. In that case, users only need to check Err() != nil.

Open questions:

  • Are users still able to differentiate between errors and server-invalidated change stream cursors (i.e. will ID() only return 0 for invalidated change streams, or any error)?
  • Should we implement the same behavior for tailable cursors?


 Comments   
Comment by Matt Dale [ 10/Apr/23 ]

Scheduling this for Go Driver 2.0.

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