-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-3991 Add versioned API connection examples #805
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
Conversation
* For a sharded cluster, connect to the mongos instances; e.g. | ||
* uri_sharded = | ||
* "mongodb://mongos0.example.com:27017,mongos1.example.com:27017/"; | ||
* client = test_framework_client_new (uri_sharded); |
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.
* client = test_framework_client_new (uri_sharded); | |
* client = mongoc_client_new (uri_sharded); |
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.
Ah, great catch. I copied this from the transactions tests where this is also part of the public sample. I've changed that occurrence as well.
server_api = mongoc_server_api_new (server_api_version); | ||
|
||
mongoc_client_set_server_api (client, server_api, &error); | ||
/* End Versioned API Example 1 */ |
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.
Needs a mongoc_client_destroy (client)
and mongoc_server_api_destroy (server_api)
.
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.
Added in all 4 tests (outside of the sample code)
server_api = mongoc_server_api_new (server_api_version); | ||
mongoc_server_api_strict (server_api, true); | ||
|
||
mongoc_client_set_server_api (client, server_api, &error); |
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.
Needs a mongoc_client_destroy (client)
and mongoc_server_api_destroy (server_api)
.
mongoc_server_api_strict (server_api, false); | ||
|
||
mongoc_client_set_server_api (client, server_api, &error); | ||
/* End Versioned API Example 3 */ |
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.
Needs a mongoc_client_destroy (client)
and mongoc_server_api_destroy (server_api)
.
mongoc_server_api_deprecation_errors (server_api, true); | ||
|
||
mongoc_client_set_server_api (client, server_api, &error); | ||
/* End Versioned API Example 4 */ |
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.
Needs a mongoc_client_destroy (client)
and mongoc_server_api_destroy (server_api)
.
@@ -3648,6 +3776,7 @@ test_sample_commands (void) | |||
if (!test_framework_max_wire_version_at_least (WIRE_VERSION_4_4)) { | |||
test_sample_txn_commands (client); | |||
} | |||
test_sample_versioned_api (); |
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.
This should skip on pre-5.0 servers.
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.
Done
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
…umentCount (mongodb#805) Update Doxygen text for count_documents() to mention estimated_document_count(), some users found it difficult to discover one from the other. https://jira.mongodb.org/browse/CXX-1774 Signed-off-by: Jesse Williamson <[email protected]>
CDRIVER-3991