MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
client_session.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/v1/client_session-fwd.hpp> // IWYU pragma: export
18
19//
20
22
25
28
30
32
33#include <cstdint>
34#include <functional>
35
36namespace mongocxx {
37namespace v1 {
38
47 private:
48 class impl;
49 void* _impl;
50
51 public:
52 class options;
53
83
90
98
106
111
115 client_session& operator=(client_session const&) = delete;
116
121
126
132 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) id() const;
133
140
146 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::types::b_timestamp) operation_time() const;
147
151 MONGOCXX_ABI_EXPORT_CDECL(std::uint32_t) server_id() const;
152
157
162
169
176
183
192
200
207
220
256 with_transaction_cb const& fn,
257 v1::transaction_options const& opts);
258
264
265 class internal;
266
267 private:
268 /* explicit(false) */ client_session(void* impl);
269};
270
280 private:
281 void* _impl; // mongoc_session_opt_t
282
283 public:
290
298
305 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
306
311
315 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
316
324
329
334
339
344
349
354
355 class internal;
356
357 private:
358 /* explicit(false) */ options(void* impl);
359};
360
361} // namespace v1
362} // namespace mongocxx
363
364#include <mongocxx/v1/detail/postlude.hpp>
365
Options for mongocxx::v1::client_session.
Definition client_session.hpp:279
options & default_transaction_opts(v1::transaction_options const &v)
Set the "defaultTransactionOptions" field.
options & snapshot(bool v)
Set the "snapshot" field.
options(options &&other) noexcept
Move constructor.
options & causal_consistency(bool v)
Set the "causalConsistency" field.
bsoncxx::v1::document::view cluster_time() const
Return this session's current "clusterTime" value.
client_session(client_session &&other) noexcept
Move constructor.
void advance_operation_time(bsoncxx::v1::types::b_timestamp v)
Advance the "operationTime" value for this session.
v1::client const & client() const
Return the associated client object.
bsoncxx::v1::types::b_timestamp operation_time() const
Return this session's current "operationTime" value.
void start_transaction(v1::transaction_options const &opts)
Start a new transaction using opts instead of default transaction options.
std::uint32_t server_id() const
Return the ID of the current pinned server.
~client_session()
Destroy this object.
transaction_state get_transaction_state() const
Return the current transaction state.
bool get_dirty() const
Return true when the current session is dirty.
std::function< void(client_session &)> with_transaction_cb
The callback function to invoke within a standalone transaction.
Definition client_session.hpp:219
transaction_state
The state of an associated transaction.
Definition client_session.hpp:57
@ k_transaction_none
No associated transaction.
Definition client_session.hpp:61
@ k_transaction_in_progress
The associated transaction is in progress.
Definition client_session.hpp:71
@ k_transaction_committed
The associated transaction was committed.
Definition client_session.hpp:76
@ k_transaction_aborted
The associated transaction was aborted.
Definition client_session.hpp:81
@ k_transaction_starting
An associated transaction has started.
Definition client_session.hpp:66
void abort_transaction()
Abort the current transaction.
void commit_transaction()
Commit the current transaction.
options opts() const
Return the options used to create this client session.
void advance_cluster_time(bsoncxx::v1::document::view v)
Advance the "clusterTime" value for this session.
void with_transaction(with_transaction_cb const &fn, v1::transaction_options const &opts)
Start and commit a new standalone transaction using fn.
Options related to a distributed transaction.
Definition transaction_options.hpp:48
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_CDECL
Expands to __cdecl when built with MSVC on Windows.
Definition export.hpp:49
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 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.
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v1::transaction_options.
Declares mongocxx::v1::client.
Declares mongocxx::v1::client_session.
Declares bsoncxx::v1::document::view.
Provides std::optional-related polyfills for library API usage.
Declares non-owning, read-only entities representing a BSON type value.