MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
transaction.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/options/transaction-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/transaction_options.hpp> // IWYU pragma: export
22
23#include <chrono>
24#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
25#include <utility>
26
27#include <mongocxx/client_session-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
31
33
35
36namespace mongocxx {
37namespace v_noabi {
38namespace options {
39
44 private:
46
47 public:
51 transaction() = default;
52
57
62
66 transaction(transaction&& other) noexcept = default;
67
71 transaction& operator=(transaction&& other) noexcept = default;
72
76 ~transaction() noexcept = default;
77
81 /* explicit(false) */ transaction(v1::transaction_options txn) : _txn{std::move(txn)} {}
82
89 explicit operator v1::transaction_options() && {
90 return std::move(_txn);
91 }
92
96 explicit operator v1::transaction_options() const& {
97 return _txn;
98 }
99
111
120
133
144
157
166
177
185 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::chrono::milliseconds>) max_commit_time_ms() const;
186
187 class internal;
188};
189
190} // namespace options
191} // namespace v_noabi
192} // namespace mongocxx
193
194namespace mongocxx {
195namespace v_noabi {
196
201 return {std::move(v)};
202}
203
210
211} // namespace v_noabi
212} // namespace mongocxx
213
215
A polyfill for std::optional<T>.
Definition optional.hpp:799
transaction()=default
Default initialization.
Options related to a distributed transaction.
Definition transaction_options.hpp:50
Used by MongoDB transaction operations.
Definition transaction.hpp:43
operator v1::transaction_options() &&
Convert to the mongocxx::v1 equivalent.
Definition transaction.hpp:89
transaction & read_preference(v_noabi::read_preference const &rp)
Sets the transaction read preference.
transaction & write_concern(v_noabi::write_concern const &wc)
Sets the transaction write concern.
transaction & read_concern(v_noabi::read_concern const &rc)
Sets the transaction read concern.
transaction & max_commit_time_ms(std::chrono::milliseconds ms)
Sets the transaction's max commit time, in milliseconds.
transaction()=default
Default initialization.
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v_noabi::options::transaction.
Provides mongocxx::v1::transaction_options.
Provides std::optional-related polyfills for library API usage.
Declares mongocxx::v_noabi::client_session.
Declares mongocxx::v_noabi::read_concern.
Declares mongocxx::v_noabi::read_preference.
Declares mongocxx::v_noabi::write_concern.