Skip to content

Commit

Permalink
introduce TailableCursor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoghisi committed Apr 6, 2021
1 parent fa283e4 commit 250e019
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import java.util.NoSuchElementException;

import de.bwaldvogel.mongo.bson.Document;
import de.bwaldvogel.mongo.oplog.OplogPosition;

public class EmptyCursor extends AbstractCursor {
public class EmptyCursor extends AbstractCursor implements TailableCursor {

private static final long EMPTY_CURSOR_ID = 0L;

Expand Down Expand Up @@ -33,4 +34,9 @@ public List<Document> takeDocuments(int numberToReturn) {
public String toString() {
return getClass().getSimpleName() + "()";
}

@Override
public OplogPosition getPosition() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.bwaldvogel.mongo.backend;

import de.bwaldvogel.mongo.oplog.OplogPosition;

public interface TailableCursor extends Cursor {

OplogPosition getPosition();

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import java.util.List;

import de.bwaldvogel.mongo.backend.AbstractCursor;
import de.bwaldvogel.mongo.backend.TailableCursor;
import de.bwaldvogel.mongo.bson.Document;

class InvalidateOplogCursor extends AbstractCursor {
class InvalidateOplogCursor extends AbstractCursor implements TailableCursor {
private final OplogPosition position;

InvalidateOplogCursor(OplogPosition position) {
Expand All @@ -27,4 +28,8 @@ public List<Document> takeDocuments(int numberToReturn) {
return Collections.singletonList(result);
}

@Override
public OplogPosition getPosition() {
return null;
}
}
6 changes: 4 additions & 2 deletions core/src/main/java/de/bwaldvogel/mongo/oplog/OplogCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import de.bwaldvogel.mongo.backend.CollectionUtils;
import de.bwaldvogel.mongo.backend.AbstractCursor;
import de.bwaldvogel.mongo.backend.TailableCursor;
import de.bwaldvogel.mongo.bson.Document;

public class OplogCursor extends AbstractCursor {
public class OplogCursor extends AbstractCursor implements TailableCursor {

private final Function<OplogPosition, Stream<Document>> oplogStream;
private OplogPosition position;
Expand Down Expand Up @@ -51,7 +52,8 @@ private void emulateWaitingForAllShards() {
}
}

OplogPosition getPosition() {
@Override
public OplogPosition getPosition() {
return position;
}

Expand Down

0 comments on commit 250e019

Please sign in to comment.