MongoDB C++ Driver current
Loading...
Searching...
No Matches
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:
63 enum class read_mode : std::uint8_t {
68
73
78
83
88 };
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;
313 friend ::mongocxx::v_noabi::search_index_view;
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.
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
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:49
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > tags() const
Sets or updates the tag set list for this read_preference.
bsoncxx::v_noabi::stdx::optional< std::chrono::seconds > max_staleness() const
Returns the current max staleness setting for this read_preference.
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.
@ k_primary
Only read from a primary node.
@ k_secondary_preferred
Prefer to read from secondary nodes.
@ k_secondary
Only read from secondary nodes.
@ k_primary_preferred
Prefer to read from a primary node.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > const hedge() const
Gets the current hedge document to be used for the read preference.
read_mode mode() const
Returns the current read_mode 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.
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.