Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/mongocxx/include/mongocxx/v1/client_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <bsoncxx/v1/types/view-fwd.hpp>

#include <mongocxx/v1/client-fwd.hpp>
#include <mongocxx/v1/transaction-fwd.hpp>
#include <mongocxx/v1/transaction_options-fwd.hpp>

#include <bsoncxx/v1/stdx/optional.hpp>

Expand Down Expand Up @@ -183,7 +183,7 @@ class client_session {
///
/// @throws mongocxx::v1::exception when a client-side error is encountered.
///
MONGOCXX_ABI_EXPORT_CDECL(void) start_transaction(v1::transaction opts);
MONGOCXX_ABI_EXPORT_CDECL(void) start_transaction(v1::transaction_options opts);

///
/// Start a new transaction.
Expand Down Expand Up @@ -256,11 +256,13 @@ class client_session {
/// @throws mongocxx::v1::exception when a client-side error is encountered.
/// @throws mongocxx::v1::server_error when a server-side error is encountered and all retry attempts have failed.
///
MONGOCXX_ABI_EXPORT_CDECL(void) with_transaction(with_transaction_cb const& fn, v1::transaction const& opts);
MONGOCXX_ABI_EXPORT_CDECL(void) with_transaction(
with_transaction_cb const& fn,
v1::transaction_options const& opts);

///
/// Equivalent to @ref with_transaction(with_transaction_cb const& fn, v1::transaction const& opts) with a
/// default-initialized @ref v1::transaction.
/// Equivalent to @ref with_transaction(with_transaction_cb const& fn, v1::transaction_options const& opts) with a
/// default-initialized @ref v1::transaction_options.
///
MONGOCXX_ABI_EXPORT_CDECL(void) with_transaction(with_transaction_cb const& fn);
};
Expand Down Expand Up @@ -344,12 +346,12 @@ class client_session::options {
///
/// Set the "defaultTransactionOptions" field.
///
MONGOCXX_ABI_EXPORT_CDECL(options&) default_transaction_opts(v1::transaction v);
MONGOCXX_ABI_EXPORT_CDECL(options&) default_transaction_opts(v1::transaction_options v);

///
/// Return the current "defaultTransactionOptions" field.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::transaction>) default_transaction_opts() const;
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::transaction_options>) default_transaction_opts() const;
};

} // namespace v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace mongocxx {
namespace v1 {

class transaction;
class transaction_options;

} // namespace v1
} // namespace mongocxx
Expand All @@ -28,5 +28,5 @@ class transaction;

///
/// @file
/// Declares @ref mongocxx::v1::transaction.
/// Declares @ref mongocxx::v1::transaction_options.
///
Copy link
Collaborator

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.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include <mongocxx/v1/transaction-fwd.hpp> // IWYU pragma: export
#include <mongocxx/v1/transaction_options-fwd.hpp> // IWYU pragma: export

//

Expand Down Expand Up @@ -47,7 +47,7 @@ namespace v1 {
///
/// @attention This feature is experimental! It is not ready for use!
///
class transaction {
class transaction_options {
private:
void* _impl; // mongoc_transaction_opt_t

Expand All @@ -57,56 +57,60 @@ class transaction {
///
/// @warning Invalidates all associated views.
///
MONGOCXX_ABI_EXPORT_CDECL() ~transaction();
MONGOCXX_ABI_EXPORT_CDECL() ~transaction_options();

///
/// Move constructor.
///
/// @par Postconditions:
/// - `other` is in an assign-or-destroy-only state.
///
MONGOCXX_ABI_EXPORT_CDECL() transaction(transaction&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() transaction_options(transaction_options&& other) noexcept;

///
/// Move assignment.
///
/// @par Postconditions:
/// - `other` is in an assign-or-destroy-only state.
///
MONGOCXX_ABI_EXPORT_CDECL(transaction&) operator=(transaction&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) operator=(transaction_options&& other) noexcept;

///
/// Copy construction.
///
MONGOCXX_ABI_EXPORT_CDECL() transaction(transaction const& other);
MONGOCXX_ABI_EXPORT_CDECL() transaction_options(transaction_options const& other);

///
/// Copy assignment.
///
MONGOCXX_ABI_EXPORT_CDECL(transaction&) operator=(transaction const& other);
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) operator=(transaction_options const& other);

///
/// Default initialization.
///
/// @par Postconditions:
/// - All supported fields are "unset" or zero-initialized.
///
MONGOCXX_ABI_EXPORT_CDECL() transaction();
MONGOCXX_ABI_EXPORT_CDECL() transaction_options();

///
/// Set the "maxCommitTimeMS" field.
///
MONGOCXX_ABI_EXPORT_CDECL(transaction&) max_commit_time_ms(std::chrono::milliseconds v);
/// @note `0` is equivalent to "unset".
///
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) max_commit_time_ms(std::chrono::milliseconds v);

///
/// Return the current "maxCommitTimeMS" field.
///
/// @note `0` is equivalent to "unset".
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<std::chrono::milliseconds>) max_commit_time_ms() const;

///
/// Set the "readConcern" field.
///
MONGOCXX_ABI_EXPORT_CDECL(transaction&) read_concern(v1::read_concern const& v);
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) read_concern(v1::read_concern const& v);

///
/// Return the current "readConcern" field.
Expand All @@ -116,7 +120,7 @@ class transaction {
///
/// Set the "readPreference" field.
///
MONGOCXX_ABI_EXPORT_CDECL(transaction&) read_preference(v1::read_preference const& v);
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) read_preference(v1::read_preference const& v);

///
/// Return the current "readPreference" field.
Expand All @@ -126,12 +130,17 @@ class transaction {
///
/// Set the "writeConcern" field.
///
MONGOCXX_ABI_EXPORT_CDECL(transaction&) write_concern(v1::write_concern const& v);
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) write_concern(v1::write_concern const& v);

///
/// Return the current "writeConcern" field.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::write_concern>) write_concern() const;

class internal;

private:
/* explicit(false) */ transaction_options(void* impl);
};

} // namespace v1
Expand All @@ -141,5 +150,5 @@ class transaction {

///
/// @file
/// Provides @ref mongocxx::v1::transaction.
/// Provides @ref mongocxx::v1::transaction_options.
///
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#pragma once

#include <mongocxx/v1/transaction_options-fwd.hpp> // IWYU pragma: export

#include <mongocxx/config/prelude.hpp>

namespace mongocxx {
Expand All @@ -29,7 +31,7 @@ class transaction;
namespace mongocxx {
namespace options {

using ::mongocxx::v_noabi::options::transaction;
using v_noabi::options::transaction;

} // namespace options
} // namespace mongocxx
Expand All @@ -40,3 +42,6 @@ using ::mongocxx::v_noabi::options::transaction;
/// @file
/// Declares @ref mongocxx::v_noabi::options::transaction.
///
/// @par Includes
/// - @ref mongocxx/v1/transaction_options-fwd.hpp
///
Loading