MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
read_preference.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 <chrono>
18#include <cstdint>
19#include <memory>
20#include <string>
21
29#include <mongocxx/uri-fwd.hpp>
30
34
36
38
39namespace mongocxx {
40namespace v_noabi {
41
50 public:
89
94
95 // @cond DOXYGEN_DISABLE
96 struct deprecated_tag {};
97 // @endcond
98
108
109 // @cond DOXYGEN_DISABLE
111 // @endcond
112
128 bsoncxx::v_noabi::document::view_or_value tags);
129
130 // @cond DOXYGEN_DISABLE
132 read_preference(read_mode mode, bsoncxx::v_noabi::document::view_or_value tags, deprecated_tag);
133 // @endcond
134
139
144
149
154
159
171
178
193 tags(bsoncxx::v_noabi::document::view_or_value tag_set_list);
194
209 tags(bsoncxx::v_noabi::array::view_or_value tag_set_list);
210
219 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view>)
220 tags() const;
221
253
259 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::chrono::seconds>)
261
283 bsoncxx::v_noabi::document::view_or_value hedge);
284
293 bsoncxx::v_noabi::document::view> const)
294 hedge() const;
295
302 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(read_preference const&, read_preference const&);
303 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator!=(read_preference const&, read_preference const&);
306
307 private:
308 friend ::mongocxx::v_noabi::client;
309 friend ::mongocxx::v_noabi::collection;
310 friend ::mongocxx::v_noabi::database;
311 friend ::mongocxx::v_noabi::events::topology_description;
312 friend ::mongocxx::v_noabi::options::transaction;
314 friend ::mongocxx::v_noabi::uri;
315
316 class impl;
317
318 read_preference(std::unique_ptr<impl>&& implementation);
319
320 std::unique_ptr<impl> _impl;
321};
322
323} // namespace v_noabi
324} // namespace mongocxx
325
326#include <mongocxx/config/postlude.hpp>
327
Provides bsoncxx::v_noabi::array::view_or_value.
read_preference()
Constructs a new read_preference with read_mode set to k_primary.
A client connection to a MongoDB server.
Definition client.hpp:61
A MongoDB collection.
Definition collection.hpp:87
A MongoDB database.
Definition database.hpp:46
read_preference & mode(read_mode mode)
Sets a new mode for this read_preference.
read_preference & max_staleness(std::chrono::seconds max_staleness)
Sets the max staleness setting for this read_preference. Secondary servers with an estimated lag grea...
read_mode
Determines which members in a replica set are acceptable to read from.
Definition read_preference.hpp:63
@ k_nearest
Read from the node with the lowest latency irrespective of state.
Definition read_preference.hpp:87
@ k_primary
Only read from a primary node.
Definition read_preference.hpp:67
@ k_secondary_preferred
Prefer to read from secondary nodes.
Definition read_preference.hpp:82
@ k_secondary
Only read from secondary nodes.
Definition read_preference.hpp:77
@ k_primary_preferred
Prefer to read from a primary node.
Definition read_preference.hpp:72
read_preference()
Constructs a new read_preference with read_mode set to k_primary.
read_preference & hedge(bsoncxx::v_noabi::document::view_or_value hedge)
Sets the hedge document to be used for the read preference. Sharded clusters running MongoDB 4....
read_preference & tags(bsoncxx::v_noabi::document::view_or_value tag_set_list)
Sets or updates the tag set list for this read_preference.
A MongoDB Atlas Search Index.
Definition search_index_view.hpp:26
A MongoDB connection string URI.
Definition uri.hpp:43
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::database.
Provides bsoncxx::v_noabi::document::view_or_value.
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition export.hpp:25
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities describing APM events.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v_noabi::read_preference.
Declares mongocxx::v_noabi::search_index_view.
Declares mongocxx::v_noabi::events::topology_description.
Declares mongocxx::v_noabi::options::transaction.
Provides mongocxx::v_noabi::options::transaction.
Declares mongocxx::v_noabi::uri.
Provides std::optional-related polyfills for library API usage.