MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
mongocxx::v1::read_preference Class Reference

#include <mongocxx/v1/read_preference.hpp>

Description

Options related to a MongoDB Read Preference.

Supported fields include:

See also
Attention
This feature is experimental! It is not ready for use!

Public Types

enum class  read_mode
 The read preference mode. More...

Public Member Functions

 read_preference ()
 Default initialization.
 read_preference (read_preference &&other) noexcept
 Move constructor.
 read_preference (read_preference const &other)
 Copy construction.
 ~read_preference ()
 Destroy this object.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::viewhedge () const
 Return the current "hedge" field.
read_preferencehedge (bsoncxx::v1::document::view v)
 Set the "hedge" field.
bsoncxx::v1::stdx::optional< std::chrono::seconds > max_staleness () const
 Return the current "maxStalenessSeconds" field.
read_preferencemax_staleness (std::chrono::seconds v)
 Set the "maxStalenessSeconds" field.
read_mode mode () const
 Return the current "mode" field.
read_preferencemode (read_mode v)
 Set the "mode" field.
read_preferenceoperator= (read_preference &&other) noexcept
 Move assignment.
read_preferenceoperator= (read_preference const &other)
 Copy assignment.
bsoncxx::v1::array::view tags () const
 Return the current "tag_sets" field.
read_preferencetags (bsoncxx::v1::array::view v)
 Set the "tag_sets" field.
read_preferencetags (bsoncxx::v1::document::view v)
 Set the "tag_sets" field.

Friends

bool operator== (read_preference const &lhs, read_preference const &rhs)
 Compare equal when all supported fields compare equal.
bool operator!= (read_preference const &lhs, read_preference const &rhs)
 Compare equal when all supported fields compare equal.

Member Enumeration Documentation

◆ read_mode

The read preference mode.

See also
Attention
This feature is experimental! It is not ready for use!
Enumerator
k_primary 

Primary member only (default).

k_primary_preferred 

Primary member when available, secondary otherwise.

k_secondary 

Secondary members only.

k_secondary_preferred 

Secondary members when available, primary otherwise.

k_nearest 

A random eligible member based on a specified latency threshold.

Constructor & Destructor Documentation

◆ ~read_preference()

mongocxx::v1::read_preference::~read_preference ( )

Destroy this object.

◆ read_preference() [1/3]

mongocxx::v1::read_preference::read_preference ( read_preference && other)
noexcept

Move constructor.

Postconditions:
  • other is in an assign-or-destroy-only state.

◆ read_preference() [2/3]

mongocxx::v1::read_preference::read_preference ( read_preference const & other)

Copy construction.

◆ read_preference() [3/3]

mongocxx::v1::read_preference::read_preference ( )

Default initialization.

Postconditions:
  • All supported fields are "unset" or zero-initialized.

Member Function Documentation

◆ hedge() [1/2]

bsoncxx::v1::stdx::optional< bsoncxx::v1::document::view > mongocxx::v1::read_preference::hedge ( ) const

Return the current "hedge" field.

Deprecated
Deprecated in MongoDB Server version 8.0.

◆ hedge() [2/2]

read_preference & mongocxx::v1::read_preference::hedge ( bsoncxx::v1::document::view v)

Set the "hedge" field.

Deprecated
Deprecated in MongoDB Server version 8.0.

◆ max_staleness() [1/2]

bsoncxx::v1::stdx::optional< std::chrono::seconds > mongocxx::v1::read_preference::max_staleness ( ) const

Return the current "maxStalenessSeconds" field.

Returns
An empty optional if the option is unset.

◆ max_staleness() [2/2]

read_preference & mongocxx::v1::read_preference::max_staleness ( std::chrono::seconds v)

Set the "maxStalenessSeconds" field.

Parameters
v-1 is equivalent to "unset".

◆ mode() [1/2]

read_mode mongocxx::v1::read_preference::mode ( ) const

Return the current "mode" field.

◆ mode() [2/2]

◆ operator=() [1/2]

read_preference & mongocxx::v1::read_preference::operator= ( read_preference && other)
noexcept

Move assignment.

Postconditions:
  • other is in an assign-or-destroy-only state.

◆ operator=() [2/2]

read_preference & mongocxx::v1::read_preference::operator= ( read_preference const & other)

Copy assignment.

◆ tags() [1/3]

bsoncxx::v1::array::view mongocxx::v1::read_preference::tags ( ) const

Return the current "tag_sets" field.

◆ tags() [2/3]

read_preference & mongocxx::v1::read_preference::tags ( bsoncxx::v1::array::view v)

Set the "tag_sets" field.

◆ tags() [3/3]

read_preference & mongocxx::v1::read_preference::tags ( bsoncxx::v1::document::view v)

Set the "tag_sets" field.

◆ operator!=

bool operator!= ( read_preference const & lhs,
read_preference const & rhs )
friend

Compare equal when all supported fields compare equal.

◆ operator==

bool operator== ( read_preference const & lhs,
read_preference const & rhs )
friend

Compare equal when all supported fields compare equal.


The documentation for this class was generated from the following file: