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

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

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.0.0
    • None
    • Query Operations
    • None

    Description

      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
          }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: