userver: storages::mongo::options::ReadPreference Class Reference
Loading...
Searching...
No Matches
storages::mongo::options::ReadPreference Class Reference

#include <userver/storages/mongo/options.hpp>

Detailed Description

Read preference.

See also
https://docs.mongodb.com/manual/reference/read-preference/

Definition at line 27 of file options.hpp.

Public Types

enum  Mode {
  kPrimary ,
  kSecondary ,
  kPrimaryPreferred ,
  kSecondaryPreferred ,
  kNearest
}
 

Public Member Functions

 ReadPreference (Mode mode)
 
 ReadPreference (Mode mode, std::vector< formats::bson::Document > tags)
 
Mode GetMode () const
 
std::optional< std::chrono::seconds > GetMaxStaleness () const
 
const std::vector< formats::bson::Document > & GetTags () const
 
ReadPreferenceSetMaxStaleness (std::optional< std::chrono::seconds > max_staleness)
 Sets maximum replication lag for eligible replica.
 
ReadPreferenceAddTag (formats::bson::Document tag)
 Adds a tag to the tag set.
 

Member Enumeration Documentation

◆ Mode

Enumerator
kPrimary 

read from primary, default mode

kSecondary 

read from secondary

kPrimaryPreferred 

read from primary if available, fallback to secondary

kSecondaryPreferred 

read from secondary if available, fallback to primary

kNearest 

read from any host with the lowest latency

Definition at line 29 of file options.hpp.

Member Function Documentation

◆ AddTag()

ReadPreference & storages::mongo::options::ReadPreference::AddTag ( formats::bson::Document tag)

Adds a tag to the tag set.

Note
Cannot be used with kPrimary mode.

◆ SetMaxStaleness()

ReadPreference & storages::mongo::options::ReadPreference::SetMaxStaleness ( std::optional< std::chrono::seconds > max_staleness)

Sets maximum replication lag for eligible replica.

Note
Must be at least 90 seconds, cannot be used with kPrimary mode.

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