Module: Mongo::ServerSelector
Overview
Functionality for getting an object able to select a server, given a preference.
Constant Summary
-
LOCAL_THRESHOLD =
The max latency in seconds between the closest server and other servers considered for selection.
# File 'lib/mongo/server_selector.rb', line 37 0.015.freeze
-
PREFERENCES =
Hash lookup for the selector classes based off the symbols
provided in configuration.
# File 'lib/mongo/server_selector.rb', line 58 {
nearest: Nearest,
primary: Primary,
primary_preferred: PrimaryPreferred,
secondary: Secondary,
secondary_preferred: SecondaryPreferred
}.freeze
-
PRIMARY =
# File 'lib/mongo/server_selector.rb', line 52
Options::Redacted.new(mode: :primary).freeze
-
SERVER_SELECTION_TIMEOUT =
How long to block for server selection before throwing an exception.
# File 'lib/mongo/server_selector.rb', line 42 30.freeze
-
SMALLEST_MAX_STALENESS_SECONDS =
The smallest allowed max staleness value, in seconds.
# File 'lib/mongo/server_selector.rb', line 47 90
Instance Method Summary
Instance Method Details
#get(preference = {})
Create a server selector object.
[ GitHub ]
#primary
This method is for internal use only.
Returns the primary server selector.
A call to this method is equivalent to ‘get(mode: :primary
)`, except the resulting server selector object is cached and not recreated each time.
[ GitHub ]
# File 'lib/mongo/server_selector.rb', line 87
def primary
@primary ||= get(mode: :primary)
end