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

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 

Default mode. All operations read from the current replica set primary.

kSecondary 

All operations read from among the nearest secondary members of the replica set.

kPrimaryPreferred 

In most situations, operations read from the primary but if it is unavailable, operations read from secondary members.

kSecondaryPreferred 

In most situations, operations read from among the nearest secondary members, but if no secondaries are available, operations read from the primary.

kNearest 

Operations read from among the nearest members of the replica set, irrespective of the member's type.

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: