Skip to content

DOCSP-43081: Change Streams - #37

Merged
mcmorisi merged 4 commits into
mongodb:standardizationfrom
mcmorisi:DOCSP-43081-change-streams
Sep 18, 2024
Merged

mcmorisi merged 4 commits into
mongodb:standardizationfrom
mcmorisi:DOCSP-43081-change-streams

Conversation

@mcmorisi

@mcmorisi mcmorisi commented Sep 16, 2024

Copy link
Copy Markdown
Collaborator

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

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

@mcmorisi
mcmorisi changed the base branch from master to standardization September 16, 2024 20:04
@netlify

netlify Bot commented Sep 16, 2024

Copy link
Copy Markdown

Deploy Preview for docs-c ready!

Name Link
🔨 Latest commit 067c814
🔍 Latest deploy log https://app.netlify.com/sites/docs-c/deploys/66eb36409aab69000801b523
😎 Deploy Preview https://deploy-preview-37--docs-c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jordan-smith721 jordan-smith721 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread 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

Copy link
Copy Markdown
Contributor

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

Suggested change
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

Comment thread 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scope of events you want to observe.
scope of events you want to observe:

Comment thread source/read/change-streams.txt Outdated
Comment on lines +42 to +44
- ``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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ``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

Comment thread source/read/change-streams.txt Outdated
Comment on lines +101 to +102
change events. Format the parameter as a list of objects that each represents an
aggregation stage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S:

Suggested change
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.

Comment thread source/read/change-streams.txt Outdated
- ``$set``
- ``$unset``

Match Specific events Example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Match Specific events Example
Match Specific Events Example

Comment thread 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to open a change stream that only records update operations:
to open a change stream that records only update operations:

@mcmorisi
mcmorisi marked this pull request as ready for review September 17, 2024 16:54

@jordan-smith721 jordan-smith721 left a comment

Copy link
Copy Markdown
Contributor

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!

Comment thread 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@mcmorisi
mcmorisi requested a review from kevinAlbs September 17, 2024 18:34

@kevinAlbs kevinAlbs left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread source/includes/read/change-streams.c Outdated
mongoc_change_stream_t *change_stream =
mongoc_collection_watch (collection, pipeline, opts);

while (mongoc_change_stream_next (change_stream, &doc)) {

Copy link
Copy Markdown
Collaborator

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;
  }
}

@mcmorisi
mcmorisi merged commit a661697 into mongodb:standardization Sep 18, 2024
@mcmorisi
mcmorisi deleted the DOCSP-43081-change-streams branch September 18, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants