-
Notifications
You must be signed in to change notification settings - Fork 548
v1: transaction (CXX-3237, CXX-3238) #1535
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
kevinAlbs
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 with minor comments and a possible rename of v1::transaction to v1::transaction_options.
src/mongocxx/test/v1/transaction.cpp
Outdated
| transaction target; | ||
|
|
||
| auto const source_secs = secs{123}; | ||
| auto const target_secs = secs{123}; |
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.
Use different value to ensure target is overwritten:
| auto const target_secs = secs{123}; | |
| auto const target_secs = secs{456}; |
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.
It did not occur to me in #1491, but I vote for renaming transaction to transaction_options.
I think v1::transaction may give the impression it is responsible for performing a transaction. And transaction_options better matches the name in the specification: TransactionOptions.
| MONGOCXX_ABI_EXPORT_CDECL() transaction(); | ||
|
|
||
| /// | ||
| /// Set the "maxCommitTimeMS" field. |
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.
| /// Set the "maxCommitTimeMS" field. 0 is equivalent to "unset". |
Suggest noting 0 is a special case, since this is not mentioned in the specification.
Resolves CXX-3237 and CXX-3238 for the
v1::transactioncomponent.Unlike recently-reviewed PRs, the
v_noabi::options::transactionclass does not containT const&getters, thus it can be fully reimplemented in terms ofv1::transaction. However, unlike previously-reviewed PRs for classes which were reimplemented in terms of v1, this is the first class which may throw an "invalid object" exception for the assign-or-destroy-only state. In order to preserve v_noabi API backward compatibility while respecting the v1 API's own assign-or-destroy-only invariants, thecheck_moved_from()helper implements the null check by reusing the (unchecked) raw pointer returned by the v1as_mongoc()internal helper function. This pattern will also used by upcoming components/PRs for other classes which may throw an "invalid object" exception for backward compatibility (that is, classes which have a potentially-throwing_get_impl()helper).