com.mongodb.reactivestreams.client.ChangeStreamPublisher Java Examples

The following examples show how to use com.mongodb.reactivestreams.client.ChangeStreamPublisher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChangeStreamOptions.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public <T> ChangeStreamPublisher<T> apply(ChangeStreamPublisher<T> stream) {
    ChangeStreamPublisher<T> publisher = stream;
    if (collation != null) {
        publisher = publisher.collation(collation);
    }
    if (maxAwaitTime > 0) {
        publisher = publisher.maxAwaitTime(maxAwaitTime, maxAwaitTimeUnit);
    }
    if (fullDocument != null) {
        publisher = publisher.fullDocument(fullDocument);
    }
    if (resumeToken != null) {
        publisher = publisher.resumeAfter(resumeToken);
    }
    if (startAtOperationTime != null) {
        publisher = publisher.startAtOperationTime(startAtOperationTime);
    }
    return publisher;
}
 
Example #2
Source File: MongoSourceTest.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void setUp() {

    map = TestHelper.createMap(true);

    mockSourceContext = mock(SourceContext.class);
    mockMongoClient = mock(MongoClient.class);
    mockMongoDb = mock(MongoDatabase.class);
    mockMongoColl = mock(MongoCollection.class);
    mockPublisher = mock(ChangeStreamPublisher.class);

    source = new MongoSource(() -> mockMongoClient);

    when(mockMongoClient.getDatabase(anyString())).thenReturn(mockMongoDb);
    when(mockMongoDb.getCollection(anyString())).thenReturn(mockMongoColl);
    when(mockMongoColl.watch()).thenReturn(mockPublisher);
    when(mockPublisher.batchSize(anyInt())).thenReturn(mockPublisher);
    when(mockPublisher.fullDocument(any())).thenReturn(mockPublisher);

    doAnswer((invocation) -> {
        subscriber = invocation.getArgument(0, Subscriber.class);
        return null;
    }).when(mockPublisher).subscribe(any());
}
 
Example #3
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final ClientSession clientSession, final Class<TResult> resultClass) {
    return watch(clientSession, Collections.<Bson>emptyList(), resultClass);
}
 
Example #4
Source File: MongoCollectionImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final ClientSession clientSession) {
    return watch(clientSession, Document.class);
}
 
Example #5
Source File: MongoCollectionImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final ClientSession clientSession, final Class<TResult> resultClass) {
    return watch(clientSession, Collections.<Bson>emptyList(), resultClass);
}
 
Example #6
Source File: MongoCollectionImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final ClientSession clientSession, final List<? extends Bson> pipeline) {
    return watch(clientSession, pipeline, Document.class);
}
 
Example #7
Source File: MongoCollectionImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final ClientSession clientSession, final List<? extends Bson> pipeline,
                                                      final Class<TResult> resultClass) {
    return new ChangeStreamPublisherImpl<TResult>(wrapped.watch(clientSession.getWrapped(), pipeline, resultClass));
}
 
Example #8
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch() {
    return watch(Collections.<Bson>emptyList());
}
 
Example #9
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final Class<TResult> resultClass) {
    return watch(Collections.<Bson>emptyList(), resultClass);
}
 
Example #10
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final List<? extends Bson> pipeline) {
    return watch(pipeline, Document.class);
}
 
Example #11
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final List<? extends Bson> pipeline, final Class<TResult> resultClass) {
    return new ChangeStreamPublisherImpl<TResult>(wrapped.watch(pipeline, resultClass));
}
 
Example #12
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final ClientSession clientSession) {
    return watch(clientSession, Collections.<Bson>emptyList(), Document.class);
}
 
Example #13
Source File: MongoCollectionImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final List<? extends Bson> pipeline) {
    return watch(pipeline, Document.class);
}
 
Example #14
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final ClientSession clientSession, final List<? extends Bson> pipeline) {
    return watch(clientSession, pipeline, Document.class);
}
 
Example #15
Source File: MongoDatabaseImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final ClientSession clientSession, final List<? extends Bson> pipeline,
                                                      final Class<TResult> resultClass) {
    notNull("clientSession", clientSession);
    return new ChangeStreamPublisherImpl<TResult>(wrapped.watch(clientSession.getWrapped(), pipeline, resultClass));
}
 
Example #16
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch() {
    return watch(Collections.<Bson>emptyList());
}
 
Example #17
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final Class<TResult> resultClass) {
    return watch(Collections.<Bson>emptyList(), resultClass);
}
 
Example #18
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final List<? extends Bson> pipeline) {
    return watch(pipeline, Document.class);
}
 
Example #19
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final List<? extends Bson> pipeline, final Class<TResult> resultClass) {
    return new ChangeStreamPublisherImpl<TResult>(wrapped.watch(pipeline, resultClass));
}
 
Example #20
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final ClientSession clientSession) {
    return watch(clientSession, Collections.<Bson>emptyList(), Document.class);
}
 
Example #21
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final ClientSession clientSession, final Class<TResult> resultClass) {
    return watch(clientSession, Collections.<Bson>emptyList(), resultClass);
}
 
Example #22
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch(final ClientSession clientSession, final List<? extends Bson> pipeline) {
    return watch(clientSession, pipeline, Document.class);
}
 
Example #23
Source File: MongoClientImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public <TResult> ChangeStreamPublisher<TResult> watch(final ClientSession clientSession, final List<? extends Bson> pipeline,
                                                      final Class<TResult> resultClass) {
    notNull("clientSession", clientSession);
    return new ChangeStreamPublisherImpl<TResult>(wrapped.watch(clientSession.getWrapped(), pipeline, resultClass));
}
 
Example #24
Source File: ChangeStreamPublisherImpl.java    From mongo-java-driver-reactivestreams with Apache License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<TResult> resumeAfter(final BsonDocument resumeToken) {
    wrapped.resumeAfter(resumeToken);
    return this;
}
 
Example #25
Source File: MongoClientWrapper.java    From ditto with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ChangeStreamPublisher<Document> watch() {
    return mongoClient.watch();
}
 
Example #26
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private <D> ChangeStreamPublisher<D> apply(ChangeStreamOptions options, ChangeStreamPublisher<D> watch) {
    if (options == null) {
        return watch;
    }
    return options.apply(watch);
}
 
Example #27
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private <T> ChangeStreamPublisher<T> apply(ChangeStreamOptions options, ChangeStreamPublisher<T> publisher) {
    if (options == null) {
        return publisher;
    }
    return options.apply(publisher);
}
 
Example #28
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(ChangeStreamOptions options) {
    ChangeStreamPublisher<Document> publisher = apply(options, client.watch());
    return Wrappers.toMulti(publisher);
}
 
Example #29
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(Class<T> clazz, ChangeStreamOptions options) {
    ChangeStreamPublisher<T> publisher = apply(options, client.watch(clazz));
    return Wrappers.toMulti(publisher);
}
 
Example #30
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline, ChangeStreamOptions options) {
    ChangeStreamPublisher<Document> publisher = apply(options, client.watch(pipeline));
    return Wrappers.toMulti(publisher);
}