Loading...
Searching...
No Matches
read_preference.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/v1/read_preference-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/array/view-fwd.hpp>
#include <bsoncxx/v1/document/view-fwd.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <chrono>
namespace mongocxx {
namespace v1 {
class read_preference {
private:
void* _impl; // mongoc_read_prefs_t
public:
enum class read_mode {
k_primary,
k_primary_preferred,
k_secondary,
k_secondary_preferred,
k_nearest,
};
MONGOCXX_ABI_EXPORT_CDECL() ~read_preference();
MONGOCXX_ABI_EXPORT_CDECL() read_preference(read_preference&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(read_preference&) operator=(read_preference&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() read_preference(read_preference const& other);
MONGOCXX_ABI_EXPORT_CDECL(read_preference&) operator=(read_preference const& other);
MONGOCXX_ABI_EXPORT_CDECL() read_preference();
MONGOCXX_DEPRECATED MONGOCXX_ABI_EXPORT_CDECL(read_preference&) hedge(bsoncxx::v1::document::view v);
MONGOCXX_DEPRECATED MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) hedge()
const;
MONGOCXX_ABI_EXPORT_CDECL(read_preference&) mode(read_mode v);
MONGOCXX_ABI_EXPORT_CDECL(read_mode) mode() const;
MONGOCXX_ABI_EXPORT_CDECL(read_preference&) tags(bsoncxx::v1::array::view v);
MONGOCXX_ABI_EXPORT_CDECL(read_preference&) tags(bsoncxx::v1::document::view v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::array::view) tags() const;
MONGOCXX_ABI_EXPORT_CDECL(read_preference&) max_staleness(std::chrono::seconds v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<std::chrono::seconds>) max_staleness() const;
friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(read_preference const& lhs, read_preference const& rhs);
friend bool operator!=(read_preference const& lhs, read_preference const& rhs) {
return !(lhs == rhs);
}
class internal;
private:
/* explicit(false) */ read_preference(void* impl);
};
} // namespace v1
} // namespace mongocxx
#include <mongocxx/v1/detail/postlude.hpp>
mongocxx::v1::read_preference::tags
read_preference & tags(bsoncxx::v1::array::view v)
Set the "tag_sets" field.
mongocxx::v1::read_preference::~read_preference
~read_preference()
Destroy this object.
mongocxx::v1::read_preference::max_staleness
read_preference & max_staleness(std::chrono::seconds v)
Set the "maxStalenessSeconds" field.
mongocxx::v1::read_preference::mode
read_preference & mode(read_mode v)
Set the "mode" field.
mongocxx::v1::read_preference::hedge
read_preference & hedge(bsoncxx::v1::document::view v)
Set the "hedge" field.
mongocxx::v1::read_preference::read_preference
read_preference()
Default initialization.
mongocxx::v1::read_preference::read_mode
read_mode
The read preference mode.
Definition read_preference.hpp:58
mongocxx::v1::read_preference::read_mode::k_nearest
@ k_nearest
A random eligible member based on a specified latency threshold.
Definition read_preference.hpp:82
mongocxx::v1::read_preference::read_mode::k_primary
@ k_primary
Primary member only (default).
Definition read_preference.hpp:62
mongocxx::v1::read_preference::read_mode::k_secondary_preferred
@ k_secondary_preferred
Secondary members when available, primary otherwise.
Definition read_preference.hpp:77
mongocxx::v1::read_preference::read_mode::k_secondary
@ k_secondary
Secondary members only.
Definition read_preference.hpp:72
mongocxx::v1::read_preference::read_mode::k_primary_preferred
@ k_primary_preferred
Primary member when available, secondary otherwise.
Definition read_preference.hpp:67
mongocxx::v1::read_preference::read_preference
read_preference(read_preference &&other) noexcept
Move constructor.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_DEPRECATED
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition export.hpp:25
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
view-fwd.hpp
Declares bsoncxx::v1::array::view.
view-fwd.hpp
Declares bsoncxx::v1::document::view.
read_preference-fwd.hpp
Declares mongocxx::v1::read_preference.
optional.hpp
Provides std::optional-related polyfills for library API usage.