mongodb-driver v0.7.1 Mongo.ReadPreference View Source
Determines which servers are considered suitable for read operations
A read preference consists of a mode and optional tag_sets
, max_staleness_ms, and hedge
.
The mode prioritizes between primaries and secondaries to produce either a single suitable server or a list of candidate servers.
If tag_sets and maxStalenessSeconds are set, they determine which candidate servers are eligible for selection.
If hedge is set, it configures how server hedged reads are used.
The default mode is :primary
.
The default tag_sets is a list with an empty tag set: [{}].
The default max_staleness_ms is unset.
The default hedge is unset.
mode
:primary
Only an available primary is suitable.:secondary
All secondaries (and only secondaries) are candidates, but only eligible candidates (i.e. after applying tag_sets and maxStalenessSeconds) are suitable.:primary_preferred
If a primary is available, only the primary is suitable. Otherwise, all secondaries are candidates, but only eligible secondaries are suitable.:secondary_preferred
All secondaries are candidates. If there is at least one eligible secondary, only eligible secondaries are suitable. Otherwise, when there are no eligible secondaries, the primary is suitable.:nearest
The primary and all secondaries are candidates, but only eligible candidates are suitable.
Link to this section Summary
Link to this section Types
Link to this type
t()
View Source
t()
View Source
t() :: %{
mode:
:primary | :secondary | :primary_preferred | :secondary_preferred | :nearest,
tag_sets: [%{required(String.t()) => String.t()}],
max_staleness_ms: non_neg_integer(),
hedge: BSON.document()
}
t() :: %{ mode: :primary | :secondary | :primary_preferred | :secondary_preferred | :nearest, tag_sets: [%{required(String.t()) => String.t()}], max_staleness_ms: non_neg_integer(), hedge: BSON.document() }
Link to this section Functions
Link to this function
add_read_preference(cmd, opts) View Source
Add read preference to the cmd
Link to this function
mongos(config) View Source
Link to this function
Link to this function
slave_ok(config) View Source
From the specs:
Use of slaveOk
There are two usages of slaveOK:
- A driver query parameter that predated read preference modes and tag set lists.
- A wire protocol flag on OP_QUERY operations