-
Notifications
You must be signed in to change notification settings - Fork 11
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
DOCSP-43081: Change Streams #37
DOCSP-43081: Change Streams #37
Conversation
✅ Deploy Preview for docs-c ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! Just a few changes
source/read/change-streams.txt
Outdated
-------- | ||
|
||
In this guide, you can learn how to use the {+driver-short+} to monitor a **change stream**, | ||
allowing you to view real-time changes to your database. A change stream is a {+mdb-server+} feature that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: Change to data since you can open a change stream on more than just a database
allowing you to view real-time changes to your database. A change stream is a {+mdb-server+} feature that | |
allowing you to view real-time changes to your data. A change stream is a {+mdb-server+} feature that |
source/read/change-streams.txt
Outdated
-------------------- | ||
|
||
To open a change stream, call one of the following functions that corresponds to the | ||
scope of events you want to observe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scope of events you want to observe. | |
scope of events you want to observe: |
source/read/change-streams.txt
Outdated
- ``mongoc_client_watch()``: To monitor all changes in the MongoDB deployment | ||
- ``mongoc_database_watch()``: To monitor changes in all collections in the database | ||
- ``mongoc_collection_watch()``: To monitor changes in the collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ``mongoc_client_watch()``: To monitor all changes in the MongoDB deployment | |
- ``mongoc_database_watch()``: To monitor changes in all collections in the database | |
- ``mongoc_collection_watch()``: To monitor changes in the collection | |
- ``mongoc_client_watch()``: Monitors all changes in the MongoDB deployment | |
- ``mongoc_database_watch()``: Monitors changes in all collections in the database | |
- ``mongoc_collection_watch()``: Monitors changes in the collection |
source/read/change-streams.txt
Outdated
change events. Format the parameter as a list of objects that each represents an | ||
aggregation stage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S:
change events. Format the parameter as a list of objects that each represents an | |
aggregation stage. | |
change events. Format the parameter as a list of objects, where each object represents an | |
aggregation stage. |
source/read/change-streams.txt
Outdated
- ``$set`` | ||
- ``$unset`` | ||
|
||
Match Specific events Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match Specific events Example | |
Match Specific Events Example |
source/read/change-streams.txt
Outdated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The following example uses the ``pipeline`` parameter to include a ``$match`` stage | ||
to open a change stream that only records update operations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to open a change stream that only records update operations: | |
to open a change stream that records only update operations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w a small fix!
source/read/change-streams.txt
Outdated
|
||
You can pass the ``pipeline`` parameter to any watch function to modify the | ||
change stream output. This parameter allows you to watch for only specified | ||
change events. Format the parameter as a list of object, where each object represents an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change events. Format the parameter as a list of object, where each object represents an | |
change events. Format the parameter as a list of objects, where each object represents an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as-is, but added a comment to consider an alternative looping.
mongoc_change_stream_t *change_stream = | ||
mongoc_collection_watch (collection, pipeline, opts); | ||
|
||
while (mongoc_change_stream_next (change_stream, &doc)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mongoc_change_stream_next
only returns true when a change is returned within the maxAwaitTimeMS
. If no change was returned, and no error occurred, a later call to mongoc_change_stream_next
can still return a change.
If the examples are intended to show the behavior of "wait (possibly forever) until there is an event or error", then I suggest looping as follows:
while (true)
{
bson_error_t error;
if (mongoc_change_stream_next(change_stream, &doc))
{
char *str = bson_as_canonical_extended_json(doc, NULL);
printf("Received change: %s\n", str);
bson_free(str);
}
else if (mongoc_change_stream_error_document(change_stream, &error, NULL))
{
printf("Got error on change stream: %s\n", error.message);
break;
}
}
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-43081
Staging - https://deploy-preview-37--docs-c.netlify.app/read/change-streams
Self-Review Checklist