MongoDB C++ Driver mongocxx-3.4.0
Loading...
Searching...
No Matches
client_session.hpp
1// Copyright 2017-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 <memory>
18
19#include <bsoncxx/document/view.hpp>
20#include <bsoncxx/stdx/optional.hpp>
21#include <mongocxx/options/client_session.hpp>
22
23#include <mongocxx/config/prelude.hpp>
24
25namespace mongocxx {
26MONGOCXX_INLINE_NAMESPACE_BEGIN
27
28class client;
29
38class MONGOCXX_API client_session {
39 public:
44
48 client_session& operator=(client_session&&) noexcept;
49
50 client_session(const client_session&) = delete;
51 client_session& operator=(const client_session&) = delete;
52
56 ~client_session() noexcept;
57
61 const class client& client() const noexcept;
62
66 const options::client_session& options() const noexcept;
67
72 bsoncxx::document::view id() const noexcept;
73
80 bsoncxx::document::view cluster_time() const noexcept;
81
87 bsoncxx::types::b_timestamp operation_time() const noexcept;
88
97 void advance_cluster_time(const bsoncxx::document::view& cluster_time);
98
107 void advance_operation_time(const bsoncxx::types::b_timestamp& operation_time);
108
119 void start_transaction(const stdx::optional<options::transaction>& transaction_opts = {});
120
129
137
138 private:
139 friend class bulk_write;
140 friend class client;
141 friend class collection;
142 friend class database;
143 friend class index_view;
144
145 class MONGOCXX_PRIVATE impl;
146
147 // "class client" distinguishes from client() method above.
148 MONGOCXX_PRIVATE client_session(const class client* client,
149 const options::client_session& options);
150
151 MONGOCXX_PRIVATE impl& _get_impl();
152 MONGOCXX_PRIVATE const impl& _get_impl() const;
153
154 std::unique_ptr<impl> _impl;
155};
156
157MONGOCXX_INLINE_NAMESPACE_END
158} // namespace mongocxx
159
160#include <mongocxx/config/postlude.hpp>
161
Class representing a batch of write operations that can be sent to the server as a group.
Definition bulk_write.hpp:43
Use a session for a sequence of operations, optionally with causal consistency.
Definition client_session.hpp:38
void commit_transaction()
Commits a transaction on the current client session.
void abort_transaction()
Aborts a transaction on the current client session.
client_session(client_session &&) noexcept
Move constructs a session.
Class representing a client connection to MongoDB.
Definition client.hpp:57
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:85
Class representing a MongoDB database.
Definition database.hpp:44
Definition index_view.hpp:32
Class representing the optional arguments to mongocxx::client::start_session.
Definition client_session.hpp:30
Top level namespace for MongoDB C++ BSON functionality.
Definition element.hpp:24
Top level namespace for the MongoDB C++ driver.
Definition bulk_write.hpp:24