Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1326

Introduce API for tailable cursors that doesn't break Iterator contract

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.0
    • Affects Version/s: None
    • Component/s: Query Operations
    • None

      Current proposal is something like this:

      public interface TailableCursor<T> extends MongoCursor<T> {
          /** 
              Move to the next document if available, otherwise return null.
          */
          T tryNext();
      }
      

      Normal usage would just use the existing MongoCursor interface (which extends Iterator and adds a close() method), but for users that don't want to block waiting for the next document, the non-blocking tryNext() method can be used, e.g.

          while (true) {
               Document doc = cursor.tryNext();
               // do other useful work here
          }
      

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: