-
Notifications
You must be signed in to change notification settings - Fork 548
v1::write_concern (CXX-3237, CXX-3238) #1504
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
base: master
Are you sure you want to change the base?
Conversation
connorsmacd
left a comment
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!
Just a few minor comments that reflect my distaste for implicit casts and some stylistic stuff.
| class internal; | ||
|
|
||
| private: | ||
| /* explicit(false) */ write_concern(void* impl); |
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.
| /* explicit(false) */ write_concern(void* impl); | |
| explicit write_concern(void* impl); |
I don't love the idea of an implicit conversion from void*, though one could argue this is acceptable since it's private.
| libmongoc::write_concern_set_w(to_mongoc(_impl), MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED); | ||
| break; | ||
| case level::k_acknowledged: | ||
| libmongoc::write_concern_set_w(to_mongoc(_impl), 1); // MONGOC_WRITE_CONCERN_W_ACKNOWLEDGED |
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.
As far as I can tell, MONGOC_WRITE_CONCERN_W_ACKNOWLEDGED is not a real constant in the C Driver, right? If so, I find the use of SCREAMING_SNAKE_CASE here to be a tad confusing. It looks the comment is referring to a constant that does exist, which raises the question as to why the constant was not actually used (if that makes any sense). Obviously, I come from the perspective of someone who is still not terribly familiar with the C Driver.
| write_concern::write_concern(void* impl) : _impl{impl} {} | ||
|
|
||
| write_concern write_concern::internal::make(mongoc_write_concern_t* rc) { | ||
| return {rc}; |
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.
| return {rc}; | |
| return write_concern(static_cast<void*>(rc)); |
Suggest using an explicit cast to make it clear which constructor is being called. This comment also assumes you've applied the the suggestion from my other comment. If not, I would still prefer to see {static_cast<void*>(rc)}.
| template struct check<lv1 ::k_default, lv_noabi::k_default>; | ||
| template struct check<lv1 ::k_majority, lv_noabi::k_majority>; | ||
| template struct check<lv1 ::k_tag, lv_noabi::k_tag>; | ||
| template struct check<lv1 ::k_unacknowledged, lv_noabi::k_unacknowledged>; | ||
| template struct check<lv1 ::k_acknowledged, lv_noabi::k_acknowledged>; |
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.
| template struct check<lv1 ::k_default, lv_noabi::k_default>; | |
| template struct check<lv1 ::k_majority, lv_noabi::k_majority>; | |
| template struct check<lv1 ::k_tag, lv_noabi::k_tag>; | |
| template struct check<lv1 ::k_unacknowledged, lv_noabi::k_unacknowledged>; | |
| template struct check<lv1 ::k_acknowledged, lv_noabi::k_acknowledged>; | |
| template struct check<lv1::k_default, lv_noabi::k_default>; | |
| template struct check<lv1::k_majority, lv_noabi::k_majority>; | |
| template struct check<lv1::k_tag, lv_noabi::k_tag>; | |
| template struct check<lv1::k_unacknowledged, lv_noabi::k_unacknowledged>; | |
| template struct check<lv1::k_acknowledged, lv_noabi::k_acknowledged>; |
The formatting here does not look correct since I don't see the space after the colon in other places. Maybe it's a clang-format issue?
Resolves CXX-3237 and CXX-3238 for the
v1::write_concerncomponent.The
test/private/write_concern.cpptest component is removed: it was only asserting that specific mongoc functions were being invoked by specific mongocxx functions. This behavior is broken by the v1 API + v_noabi refactor, which now uses the*_int64variants ofmongoc_write_concern_set_wtimeout()accessors and avoids callingmongoc_write_concern_set_wmajority()in favor of*_set_w() + *_set_wtimeout()individually. For backward compatibility,.to_document()avoids appending the "wtimeout" field as a$numberLongunless it is strictly necessary, otherwisewc.timeout(0).to_document().view() == scoped_bson{R"({"wtimeout": 0})"}.view()evaluates to false (int32 vs. int64).