Skip to content

Conversation

@eramongodb
Copy link
Contributor

Resolves CXX-3237 and CXX-3238 for the v1::write_concern component.

The test/private/write_concern.cpp test 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 *_int64 variants of mongoc_write_concern_set_wtimeout() accessors and avoids calling mongoc_write_concern_set_wmajority() in favor of *_set_w() + *_set_wtimeout() individually. For backward compatibility, .to_document() avoids appending the "wtimeout" field as a $numberLong unless it is strictly necessary, otherwise wc.timeout(0).to_document().view() == scoped_bson{R"({"wtimeout": 0})"}.view() evaluates to false (int32 vs. int64).

@eramongodb eramongodb requested a review from kevinAlbs November 14, 2025 21:58
@eramongodb eramongodb self-assigned this Nov 14, 2025
@eramongodb eramongodb requested a review from a team as a code owner November 14, 2025 21:58
@kevinAlbs kevinAlbs requested review from mdb-ad and removed request for kevinAlbs November 17, 2025 13:05
@eramongodb eramongodb requested review from vector-of-bool and removed request for mdb-ad November 18, 2025 16:34
@eramongodb eramongodb requested review from connorsmacd and removed request for vector-of-bool November 20, 2025 15:30
Copy link
Collaborator

@connorsmacd connorsmacd left a 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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/* 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
Copy link
Collaborator

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};
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Comment on lines +47 to +51
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>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

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.

2 participants