Loading...
Searching...
No Matches
transaction.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/transaction-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/transaction_options.hpp> // IWYU pragma: export
#include <chrono>
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <utility>
#include <mongocxx/client_session-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/read_concern-fwd.hpp>
#include <mongocxx/read_preference-fwd.hpp>
#include <mongocxx/write_concern-fwd.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class transaction {
private:
v1::transaction_options _txn;
public:
transaction() = default;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() transaction(transaction const& other);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(transaction&) operator=(transaction const& other);
transaction(transaction&& other) noexcept = default;
transaction& operator=(transaction&& other) noexcept = default;
~transaction() noexcept = default;
/* explicit(false) */ transaction(v1::transaction_options txn) : _txn{std::move(txn)} {}
explicit operator v1::transaction_options() && {
return std::move(_txn);
}
explicit operator v1::transaction_options() const& {
return _txn;
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(transaction&) read_concern(v_noabi::read_concern const& rc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::read_concern>)
read_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(transaction&)
write_concern(v_noabi::write_concern const& wc);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern>)
write_concern() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(transaction&)
read_preference(v_noabi::read_preference const& rp);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<v_noabi::read_preference>)
read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(transaction&) max_commit_time_ms(std::chrono::milliseconds ms);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::optional<std::chrono::milliseconds>) max_commit_time_ms()
const;
class internal;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::transaction from_v1(v1::transaction_options v) {
return {std::move(v)};
}
inline v1::transaction_options to_v1(v_noabi::options::transaction v) {
return v1::transaction_options{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
mongocxx::options::transaction::transaction
transaction()=default
Default initialization.
mongocxx::v1::transaction_options
Options related to a distributed transaction.
Definition transaction_options.hpp:48
mongocxx::v_noabi::options::transaction
Used by MongoDB transaction operations.
Definition transaction.hpp:43
mongocxx::v_noabi::options::transaction::transaction_options
operator v1::transaction_options() &&
Convert to the mongocxx::v1 equivalent.
Definition transaction.hpp:89
mongocxx::v_noabi::options::transaction::read_preference
transaction & read_preference(v_noabi::read_preference const &rp)
Sets the transaction read preference.
mongocxx::v_noabi::options::transaction::write_concern
transaction & write_concern(v_noabi::write_concern const &wc)
Sets the transaction write concern.
mongocxx::v_noabi::options::transaction::read_concern
transaction & read_concern(v_noabi::read_concern const &rc)
Sets the transaction read concern.
mongocxx::v_noabi::options::transaction::max_commit_time_ms
transaction & max_commit_time_ms(std::chrono::milliseconds ms)
Sets the transaction's max commit time, in milliseconds.
mongocxx::v_noabi::options::transaction::transaction
transaction()=default
Default initialization.
mongocxx::v_noabi::read_concern
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
transaction-fwd.hpp
Declares mongocxx::v_noabi::options::transaction.
transaction_options.hpp
Provides mongocxx::v1::transaction_options.
optional.hpp
Provides std::optional-related polyfills for library API usage.
client_session-fwd.hpp
Declares mongocxx::v_noabi::client_session.
read_concern-fwd.hpp
Declares mongocxx::v_noabi::read_concern.
read_preference-fwd.hpp
Declares mongocxx::v_noabi::read_preference.
write_concern-fwd.hpp
Declares mongocxx::v_noabi::write_concern.