Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2759

Return an error if a "ChangeStream" is invalidated

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Unknown Unknown
    • 2.0.0
    • None
    • Change Streams
    • None
    • Hide

      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?

      Show
      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: