MongoDB C++ Driver 4.2.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
49 private:
50 class impl;
51 void* _impl;
52
53 public:
54 class options;
55
87
94
102
110
115
119 client_session& operator=(client_session const&) = delete;
120
125
130
136 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) id() const;
137
144
150 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::types::b_timestamp) operation_time() const;
151
155 MONGOCXX_ABI_EXPORT_CDECL(std::uint32_t) server_id() const;
156
161
166
173
180
187
196
204
211
224
260 with_transaction_cb const& fn,
261 v1::transaction_options const& opts);
262
268
269 class internal;
270
271 private:
272 /* explicit(false) */ client_session(void* impl);
273};
274
286 private:
287 void* _impl; // mongoc_session_opt_t
288
289 public:
296
304
311 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
312
317
321 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
322
330
335
340
345
350
355
360
361 class internal;
362
363 private:
364 /* explicit(false) */ options(void* impl);
365};
366
367} // namespace v1
368} // namespace mongocxx
369
370#include <mongocxx/v1/detail/postlude.hpp>
371
Options for mongocxx::v1::client_session.
Definition client_session.hpp:285
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:223
transaction_state
The state of an associated transaction.
Definition client_session.hpp:61
@ k_transaction_none
No associated transaction.
Definition client_session.hpp:65
@ k_transaction_in_progress
The associated transaction is in progress.
Definition client_session.hpp:75
@ k_transaction_committed
The associated transaction was committed.
Definition client_session.hpp:80
@ k_transaction_aborted
The associated transaction was aborted.
Definition client_session.hpp:85
@ k_transaction_starting
An associated transaction has started.
Definition client_session.hpp:70
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:50
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.