MongoDB C++ Driver 4.2.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 <mongocxx/v1/read_preference-fwd.hpp> // IWYU pragma: export
18
19//
20
22
25
27
29
30#include <chrono>
31
32namespace mongocxx {
33namespace v1 {
34
50 private:
51 void* _impl; // mongoc_read_prefs_t
52
53 public:
88
93
101
109
114
119
127
134
141 const;
142
157
162
171
175 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::array::view) tags() const;
176
183
189 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<std::chrono::seconds>) max_staleness() const;
190
195 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(read_preference const& lhs, read_preference const& rhs);
196
197 friend bool operator!=(read_preference const& lhs, read_preference const& rhs) {
198 return !(lhs == rhs);
199 }
200
202
203 class internal;
204
205 private:
206 /* explicit(false) */ read_preference(void* impl);
207};
208
209} // namespace v1
210} // namespace mongocxx
211
213
read_preference & tags(bsoncxx::v1::array::view v)
Set the "tag_sets" field.
~read_preference()
Destroy this object.
read_preference & max_staleness(std::chrono::seconds v)
Set the "maxStalenessSeconds" field.
read_preference & mode(read_mode v)
Set the "mode" field.
read_preference & hedge(bsoncxx::v1::document::view v)
Set the "hedge" field.
read_preference()
Default initialization.
read_mode
The read preference mode.
Definition read_preference.hpp:62
@ k_nearest
A random eligible member based on a specified latency threshold.
Definition read_preference.hpp:86
@ k_primary
Primary member only (default).
Definition read_preference.hpp:66
@ k_secondary_preferred
Secondary members when available, primary otherwise.
Definition read_preference.hpp:81
@ k_secondary
Secondary members only.
Definition read_preference.hpp:76
@ k_primary_preferred
Primary member when available, secondary otherwise.
Definition read_preference.hpp:71
read_preference(read_preference &&other) noexcept
Move constructor.
Provides macros to control the set of symbols exported in the ABI.
#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 v1 macro guard postlude header.
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 bsoncxx::v1::array::view.
Declares bsoncxx::v1::document::view.
Declares mongocxx::v1::read_preference.
Provides std::optional-related polyfills for library API usage.