Skip to content

Commit 060fa29

Browse files
authored
v1: transaction (CXX-3237, CXX-3238) (#1535)
* CXX-3236 Rename `v1::transaction` -> `v1::transaction_options`
1 parent a86102c commit 060fa29

File tree

14 files changed

+488
-216
lines changed

14 files changed

+488
-216
lines changed

src/mongocxx/include/mongocxx/v1/client_session.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <bsoncxx/v1/types/view-fwd.hpp>
2525

2626
#include <mongocxx/v1/client-fwd.hpp>
27-
#include <mongocxx/v1/transaction-fwd.hpp>
27+
#include <mongocxx/v1/transaction_options-fwd.hpp>
2828

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

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

188188
///
189189
/// Start a new transaction.
@@ -256,11 +256,13 @@ class client_session {
256256
/// @throws mongocxx::v1::exception when a client-side error is encountered.
257257
/// @throws mongocxx::v1::server_error when a server-side error is encountered and all retry attempts have failed.
258258
///
259-
MONGOCXX_ABI_EXPORT_CDECL(void) with_transaction(with_transaction_cb const& fn, v1::transaction const& opts);
259+
MONGOCXX_ABI_EXPORT_CDECL(void) with_transaction(
260+
with_transaction_cb const& fn,
261+
v1::transaction_options const& opts);
260262

261263
///
262-
/// Equivalent to @ref with_transaction(with_transaction_cb const& fn, v1::transaction const& opts) with a
263-
/// default-initialized @ref v1::transaction.
264+
/// Equivalent to @ref with_transaction(with_transaction_cb const& fn, v1::transaction_options const& opts) with a
265+
/// default-initialized @ref v1::transaction_options.
264266
///
265267
MONGOCXX_ABI_EXPORT_CDECL(void) with_transaction(with_transaction_cb const& fn);
266268
};
@@ -344,12 +346,12 @@ class client_session::options {
344346
///
345347
/// Set the "defaultTransactionOptions" field.
346348
///
347-
MONGOCXX_ABI_EXPORT_CDECL(options&) default_transaction_opts(v1::transaction v);
349+
MONGOCXX_ABI_EXPORT_CDECL(options&) default_transaction_opts(v1::transaction_options v);
348350

349351
///
350352
/// Return the current "defaultTransactionOptions" field.
351353
///
352-
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::transaction>) default_transaction_opts() const;
354+
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::transaction_options>) default_transaction_opts() const;
353355
};
354356

355357
} // namespace v1

src/mongocxx/include/mongocxx/v1/transaction-fwd.hpp renamed to src/mongocxx/include/mongocxx/v1/transaction_options-fwd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace mongocxx {
2020
namespace v1 {
2121

22-
class transaction;
22+
class transaction_options;
2323

2424
} // namespace v1
2525
} // namespace mongocxx
@@ -28,5 +28,5 @@ class transaction;
2828

2929
///
3030
/// @file
31-
/// Declares @ref mongocxx::v1::transaction.
31+
/// Declares @ref mongocxx::v1::transaction_options.
3232
///

src/mongocxx/include/mongocxx/v1/transaction.hpp renamed to src/mongocxx/include/mongocxx/v1/transaction_options.hpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#pragma once
1616

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

1919
//
2020

@@ -47,7 +47,7 @@ namespace v1 {
4747
///
4848
/// @attention This feature is experimental! It is not ready for use!
4949
///
50-
class transaction {
50+
class transaction_options {
5151
private:
5252
void* _impl; // mongoc_transaction_opt_t
5353

@@ -57,56 +57,60 @@ class transaction {
5757
///
5858
/// @warning Invalidates all associated views.
5959
///
60-
MONGOCXX_ABI_EXPORT_CDECL() ~transaction();
60+
MONGOCXX_ABI_EXPORT_CDECL() ~transaction_options();
6161

6262
///
6363
/// Move constructor.
6464
///
6565
/// @par Postconditions:
6666
/// - `other` is in an assign-or-destroy-only state.
6767
///
68-
MONGOCXX_ABI_EXPORT_CDECL() transaction(transaction&& other) noexcept;
68+
MONGOCXX_ABI_EXPORT_CDECL() transaction_options(transaction_options&& other) noexcept;
6969

7070
///
7171
/// Move assignment.
7272
///
7373
/// @par Postconditions:
7474
/// - `other` is in an assign-or-destroy-only state.
7575
///
76-
MONGOCXX_ABI_EXPORT_CDECL(transaction&) operator=(transaction&& other) noexcept;
76+
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) operator=(transaction_options&& other) noexcept;
7777

7878
///
7979
/// Copy construction.
8080
///
81-
MONGOCXX_ABI_EXPORT_CDECL() transaction(transaction const& other);
81+
MONGOCXX_ABI_EXPORT_CDECL() transaction_options(transaction_options const& other);
8282

8383
///
8484
/// Copy assignment.
8585
///
86-
MONGOCXX_ABI_EXPORT_CDECL(transaction&) operator=(transaction const& other);
86+
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) operator=(transaction_options const& other);
8787

8888
///
8989
/// Default initialization.
9090
///
9191
/// @par Postconditions:
9292
/// - All supported fields are "unset" or zero-initialized.
9393
///
94-
MONGOCXX_ABI_EXPORT_CDECL() transaction();
94+
MONGOCXX_ABI_EXPORT_CDECL() transaction_options();
9595

9696
///
9797
/// Set the "maxCommitTimeMS" field.
9898
///
99-
MONGOCXX_ABI_EXPORT_CDECL(transaction&) max_commit_time_ms(std::chrono::milliseconds v);
99+
/// @note `0` is equivalent to "unset".
100+
///
101+
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) max_commit_time_ms(std::chrono::milliseconds v);
100102

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

106110
///
107111
/// Set the "readConcern" field.
108112
///
109-
MONGOCXX_ABI_EXPORT_CDECL(transaction&) read_concern(v1::read_concern const& v);
113+
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) read_concern(v1::read_concern const& v);
110114

111115
///
112116
/// Return the current "readConcern" field.
@@ -116,7 +120,7 @@ class transaction {
116120
///
117121
/// Set the "readPreference" field.
118122
///
119-
MONGOCXX_ABI_EXPORT_CDECL(transaction&) read_preference(v1::read_preference const& v);
123+
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) read_preference(v1::read_preference const& v);
120124

121125
///
122126
/// Return the current "readPreference" field.
@@ -126,12 +130,17 @@ class transaction {
126130
///
127131
/// Set the "writeConcern" field.
128132
///
129-
MONGOCXX_ABI_EXPORT_CDECL(transaction&) write_concern(v1::write_concern const& v);
133+
MONGOCXX_ABI_EXPORT_CDECL(transaction_options&) write_concern(v1::write_concern const& v);
130134

131135
///
132136
/// Return the current "writeConcern" field.
133137
///
134138
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::write_concern>) write_concern() const;
139+
140+
class internal;
141+
142+
private:
143+
/* explicit(false) */ transaction_options(void* impl);
135144
};
136145

137146
} // namespace v1
@@ -141,5 +150,5 @@ class transaction {
141150

142151
///
143152
/// @file
144-
/// Provides @ref mongocxx::v1::transaction.
153+
/// Provides @ref mongocxx::v1::transaction_options.
145154
///

src/mongocxx/include/mongocxx/v_noabi/mongocxx/options/transaction-fwd.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#pragma once
1616

17+
#include <mongocxx/v1/transaction_options-fwd.hpp> // IWYU pragma: export
18+
1719
#include <mongocxx/config/prelude.hpp>
1820

1921
namespace mongocxx {
@@ -29,7 +31,7 @@ class transaction;
2931
namespace mongocxx {
3032
namespace options {
3133

32-
using ::mongocxx::v_noabi::options::transaction;
34+
using v_noabi::options::transaction;
3335

3436
} // namespace options
3537
} // namespace mongocxx
@@ -40,3 +42,6 @@ using ::mongocxx::v_noabi::options::transaction;
4042
/// @file
4143
/// Declares @ref mongocxx::v_noabi::options::transaction.
4244
///
45+
/// @par Includes
46+
/// - @ref mongocxx/v1/transaction_options-fwd.hpp
47+
///

0 commit comments

Comments
 (0)