Skip to content

Commit 0c32afe

Browse files
authored
CDRIVER-4362 Add showExpandedEvents option for C2C replication (#1133)
CDRIVER-4362 Add support for dropTarget, showExpandedEvents and dropIndex
1 parent b6dad0c commit 0c32afe

File tree

8 files changed

+587
-1
lines changed

8 files changed

+587
-1
lines changed

build/generate-opts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def __init__(self, items, **defaults):
309309
'returns the value of the document before the associated '
310310
'change.',
311311
}),
312+
('showExpandedEvents', { 'type': 'bool', 'help': 'Set to ``true`` to return an expanded list of change stream events. Avaiable only on MongoDB versions >=6.0'}),
312313
comment_option_string_pre_4_4,
313314
], fullDocument=None, fullDocumentBeforeChange=None)),
314315

src/libmongoc/doc/includes/change-stream-opts.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
* ``maxAwaitTimeMS``: An ``int64`` representing the maximum amount of time a call to :symbol:`mongoc_change_stream_next` will block waiting for data
1313
* ``fullDocument``: An optional UTF-8 string. Set this option to "default", "updateLookup", "whenAvailable", or "required", If unset, The string "default" is assumed. Set this option to "updateLookup" to direct the change stream cursor to lookup the most current majority-committed version of the document associated to an update change stream event.
1414
* ``fullDocumentBeforeChange``: An optional UTF-8 string. Set this option to "whenAvailable", "required", or "off". When unset, the default value is "off". Similar to "fullDocument", but returns the value of the document before the associated change.
15+
* ``showExpandedEvents``: Set to ``true`` to return an expanded list of change stream events. Avaiable only on MongoDB versions >=6.0
1516
* ``comment``: A :symbol:`bson_value_t` specifying the comment to attach to this command. The comment will appear in log messages, profiler output, and currentOp output. Only string values are supported prior to MongoDB 4.4.

src/libmongoc/src/mongoc/mongoc-change-stream-private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct _mongoc_change_stream_t {
3939
bson_t resume_token;
4040
bson_t *full_document;
4141
bson_t *full_document_before_change;
42+
bool show_expanded_events;
4243

4344
bson_error_t err;
4445
bson_t err_doc;

src/libmongoc/src/mongoc/mongoc-change-stream.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ _make_command (mongoc_change_stream_t *stream, bson_t *command)
129129
if (stream->full_document_before_change) {
130130
bson_concat (&change_stream_doc, stream->full_document_before_change);
131131
}
132+
if (stream->show_expanded_events) {
133+
BSON_APPEND_BOOL (&change_stream_doc,
134+
"showExpandedEvents",
135+
stream->show_expanded_events);
136+
}
132137

133138
if (stream->resumed) {
134139
/* Change stream spec: Resume Process */
@@ -433,6 +438,7 @@ _change_stream_init (mongoc_change_stream_t *stream,
433438

434439
stream->batch_size = stream->opts.batchSize;
435440
stream->max_await_time_ms = stream->opts.maxAwaitTimeMS;
441+
stream->show_expanded_events = stream->opts.showExpandedEvents;
436442

437443
/* Accept two forms of user pipeline:
438444
* 1. A document like: { "pipeline": [...] }

src/libmongoc/src/mongoc/mongoc-opts-private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ typedef struct _mongoc_change_stream_opts_t {
146146
int64_t maxAwaitTimeMS;
147147
const char *fullDocument;
148148
const char *fullDocumentBeforeChange;
149+
bool showExpandedEvents;
149150
bson_value_t comment;
150151
bson_t extra;
151152
} mongoc_change_stream_opts_t;

src/libmongoc/src/mongoc/mongoc-opts.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,7 @@ _mongoc_change_stream_opts_parse (
15831583
mongoc_change_stream_opts->maxAwaitTimeMS = 0;
15841584
mongoc_change_stream_opts->fullDocument = NULL;
15851585
mongoc_change_stream_opts->fullDocumentBeforeChange = NULL;
1586+
mongoc_change_stream_opts->showExpandedEvents = false;
15861587
memset (&mongoc_change_stream_opts->comment, 0, sizeof (bson_value_t));
15871588
bson_init (&mongoc_change_stream_opts->extra);
15881589

@@ -1662,6 +1663,15 @@ _mongoc_change_stream_opts_parse (
16621663
return false;
16631664
}
16641665
}
1666+
else if (!strcmp (bson_iter_key (&iter), "showExpandedEvents")) {
1667+
if (!_mongoc_convert_bool (
1668+
client,
1669+
&iter,
1670+
&mongoc_change_stream_opts->showExpandedEvents,
1671+
error)) {
1672+
return false;
1673+
}
1674+
}
16651675
else if (!strcmp (bson_iter_key (&iter), "comment")) {
16661676
if (!_mongoc_convert_bson_value_t (
16671677
client,

0 commit comments

Comments
 (0)