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

Add TryNext API

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0
    • Component/s: CRUD
    • Labels:
      None

      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.

        Attachments

          Activity

            People

            Assignee:
            divjot.arora Divjot Arora
            Reporter:
            divjot.arora Divjot Arora
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: