Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add showExpandedEvents to change stream pipeline stage #977

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class ChangeStreamOperation<T> implements AsyncReadOperation<AsyncBatchCu
private BsonDocument resumeAfter;
private BsonDocument startAfter;
private BsonTimestamp startAtOperationTime;
private boolean showExpandedEvents;

/**
* Construct a new instance.
Expand Down Expand Up @@ -342,6 +343,33 @@ public ChangeStreamOperation<T> comment(final BsonValue comment) {
return this;
}

/**
* Gets whether to include expanded change stream events. Default false.
*
* @return true if expanded change stream events should be included.
* @since 4.7
* @mongodb.server.release 6.0
*/
public boolean getShowExpandedEvents() {
return this.showExpandedEvents;
}

/**
* Sets whether to include expanded change stream events, which are:
* createIndexes, dropIndexes, modify, create, shardCollection,
* reshardCollection, refineCollectionShardKey. False by default.
*
* @param showExpandedEvents true to include expanded events
* @return this
* @since 4.7
* @mongodb.server.release 6.0
*/
public ChangeStreamOperation<T> showExpandedEvents(final boolean showExpandedEvents) {
this.showExpandedEvents = showExpandedEvents;
return this;
}


@Override
public BatchCursor<T> execute(final ReadBinding binding) {
return withReadConnectionSource(binding, new CallableWithSource<BatchCursor<T>>() {
Expand Down Expand Up @@ -444,6 +472,10 @@ public BsonArray create() {
changeStream.append("allChangesForCluster", BsonBoolean.TRUE);
}

if (showExpandedEvents) {
changeStream.append("showExpandedEvents", BsonBoolean.TRUE);
}

if (resumeAfter != null) {
changeStream.append("resumeAfter", resumeAfter);
}
Expand Down
Loading