[CXX-1055] Add new read_preference setters that support method chaining, deprecate existing setters and constructors Created: 30/Sep/16  Updated: 07/Feb/17  Resolved: 07/Feb/17

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: None
Fix Version/s: 3.2.0-rc0

Type: New Feature Priority: Major - P3
Reporter: J Rassi Assignee: Samuel Rossi (Inactive)
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The design of the read_preference class could be improved to make it easier to add future additional options.

We should consider the following concrete improvements:

  • Adding new setters which support method chaining (i.e. have a return type of read_preference& instead of void).
  • Adding a new default constructor.
  • Deprecating the existing constructors (which take a read mode and a tag set).
  • Deprecating the existing setters.

Once these improvements are made, adding a new option to read_preference will only require adding a new getter and setter, and not touching any constructors.

In addition, using method chaining, users will create simple read preferences with e.g. read_preference().mode(read_preference::read_mode::k_secondary), which is slightly more readable than read_preference(read_preference::read_mode::k_secondary).



 Comments   
Comment by Githook User [ 07/Feb/17 ]

Author:

{u'username': u'saghm', u'name': u'Saghm Rossi', u'email': u'saghmrossi@gmail.com'}

Message: CXX-1055 Add new read_preference setters that support method chaining, deprecate existing setters and constructors
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/8909dc0f16950b19b7e150b23077028705c16293

Generated at Wed Feb 07 22:01:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.