MongoDB C++ Driver mongocxx-4.0.0
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
65 public:
78 enum class read_mode : std::uint8_t {
83
88
93
98
103 };
104
109
110 struct deprecated_tag {};
111
121
123
138 read_preference(read_mode mode, bsoncxx::v_noabi::document::view_or_value tags);
139
141 read_preference(read_mode mode, bsoncxx::v_noabi::document::view_or_value tags, deprecated_tag);
142
147
152
157
162
167
179
186
201 tags(bsoncxx::v_noabi::document::view_or_value tag_set_list);
202
217 tags(bsoncxx::v_noabi::array::view_or_value tag_set_list);
218
227 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view>)
228 tags() const;
229
261
267 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::chrono::seconds>)
269
289 hedge(bsoncxx::v_noabi::document::view_or_value hedge);
290
297 const bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view>)
298 hedge() const;
299
306 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(const read_preference&,
307 const read_preference&);
308 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator!=(const read_preference&,
309 const read_preference&);
312
313 private:
314 friend ::mongocxx::v_noabi::client;
315 friend ::mongocxx::v_noabi::collection;
316 friend ::mongocxx::v_noabi::database;
317 friend ::mongocxx::v_noabi::events::topology_description;
318 friend ::mongocxx::v_noabi::options::transaction;
319 friend ::mongocxx::v_noabi::search_index_view;
320 friend ::mongocxx::v_noabi::uri;
321
322 class impl;
323
324 read_preference(std::unique_ptr<impl>&& implementation);
325
326 std::unique_ptr<impl> _impl;
327};
328
329} // namespace v_noabi
330} // namespace mongocxx
331
332#include <mongocxx/config/postlude.hpp>
333
Provides bsoncxx::v_noabi::array::view_or_value.
Class representing a client connection to MongoDB.
Definition client.hpp:61
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:87
Class representing a MongoDB database.
Definition database.hpp:46
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:64
const bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > hedge() const
Gets the current hedge document to be used for the read preference.
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:78
@ 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.
read_mode mode() const
Returns the current read_mode for this read_preference.
Class representing a MongoDB search index view.
Definition search_index_view.hpp:24
Class representing 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 fwd.hpp:212
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:204
The mongocxx 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.
The top-level namespace reserved for the C++ standard library.
Provides std::optional-related polyfills for library API usage.
Declares mongocxx::v_noabi::read_preference.
Declares mongocxx::v_noabi::search_index_view.
Definition read_preference.hpp:110
Declares mongocxx::v_noabi::events::topology_description.
Declares mongocxx::v_noabi::options::transaction.
Provides mongocxx::v_noabi::options::transaction.
Declares mongocxx::v_noabi::uri.