[CDRIVER-1526] Rename "_with_write_concern" functions to "_with_opts" Created: 07/Sep/16  Updated: 02/Jun/18  Resolved: 13/Sep/16

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.5.0
Fix Version/s: 1.5.0

Type: New Feature Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-1322 Support sending writeConcern for comm... Closed
Problem/Incident
causes CDRIVER-2679 Finish documenting "with_opts" functions Closed
Epic Link: Flexible opts
Backwards Compatibility: Fully Compatible

 Description   

Rename "_with_write_concern" functions (introduced in CDRIVER-1322) to "_with_opts", accept a const bson_t opts instead a mongoc_write_concern_t:

  • mongoc_collection_aggregate_with_opts mongoc_collection_aggregate already has bson_t *options that be retrofitted
  • mongoc_collection_create_index_with_opts
  • mongoc_collection_drop_index_with_opts
  • mongoc_collection_drop_with_opts
  • mongoc_collection_rename_with_opts
  • mongoc_database_create_collection_with_opts mongoc_database_create_collection already has bson_t *options that can be retrofitted
  • mongoc_database_drop_with_opts

For consistency with the rest of our API, the final parameters of each of these functions should be ordered like:

   const bson_t *opts
   bson_error_t *error

Or:

   const bson_t *opts
   bson_t *reply
   bson_error_t *error

Their internal helper _mongoc_client_command_with_write_concern should become:

  • _mongoc_client_command_with_opts

This function accepts a const bson_t "opts" instead of a mongoc_write_concern_t. Users can easily pass us a mongoc_write_concern_t in "opts" using mongoc_write_concern_append. The same rules currently enforced by _mongoc_client_command_with_write_concern MUST be enforced by the new _mongoc_client_command_with_opts:

  • If "opts" has a "writeConcern" subdocument, append it to the command iff max wire version >= 5
  • If "opts" has a "writeConcern" subdocument, parse the reply for "writeConcernError" and return false if there is a write concern error

Besides "writeConcern", I think other fields in "opts" are appended to the command without any validation.



 Comments   
Comment by Githook User [ 13/Sep/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1526 Rewrite "_with_write_concern" functions to "_with_opts"

These function now take a generic bson_t options, which can contain
whichever options or arguments to the command.

To add write_concern to the these commands, add it to the generic opts
with:
mongoc_write_concern_append (wc, opts);
And pass opts to the function.

Removed

  • mongoc_collection_aggregate_with_opts
  • mongoc_database_create_collection_with_opts

Their respective function without _with_opts had opts parameter that
was retrofitted to support writeConcern and other arbitrary options
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/279c7fe7fbc4309d727d9762014e6aa49483d19e

Comment by Hannes Magnusson [ 13/Sep/16 ]

https://mongodbcr.appspot.com/98200001/

Generated at Wed Feb 07 21:12:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.