Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/mongo/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ def hash
# that the driver will communicate with for sharded topologies. If this
# option is 0, then there will be no maximum number of mongoses. If the
# given URI resolves to more hosts than ``:srv_max_hosts``, the client
# will ramdomly choose an ``:srv_max_hosts`` sized subset of hosts.
# will randomly choose an ``:srv_max_hosts`` sized subset of hosts. If
# srvMaxHosts is provided in the URI options, it takes precedence over this
# option.
# @option options [ String ] :srv_service_name The service name to use in
# the SRV DNS query.
# @option options [ true, false ] :ssl Whether to use TLS.
Expand Down
6 changes: 5 additions & 1 deletion lib/mongo/srv/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def do_work
def scan!
begin
last_result = Timeout.timeout(timeout) do
@resolver.get_records(@srv_uri.query_hostname)
@resolver.get_records(
@srv_uri.query_hostname,
@srv_uri.uri_options[:srv_service_name] || options[:srv_service_name],
@srv_uri.uri_options[:srv_max_hosts] || @options[:srv_max_hosts]
)
end
rescue Resolv::ResolvTimeout => e
log_warn("SRV monitor: timed out trying to resolve hostname #{@srv_uri.query_hostname}: #{e.class}: #{e}")
Expand Down
10 changes: 8 additions & 2 deletions lib/mongo/uri/srv_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ def raise_invalid_error!(details)
end

# Gets the SRV resolver.
# If domain verification fails or no SRV records are found,
# an error must not be raised per the spec; instead, a warning is logged.
#
# @return [ Mongo::Srv::Resolver ]
def resolver
@resolver ||= Srv::Resolver.new(
raise_on_invalid: true,
raise_on_invalid: false,
resolv_options: options[:resolv_options],
timeout: options[:connect_timeout],
)
Expand All @@ -149,7 +151,11 @@ def parse!(remaining)

log_debug "attempting to resolve #{hostname}"

@srv_result = resolver.get_records(hostname, uri_options[:srv_service_name], uri_options[:srv_max_hosts])
@srv_result = resolver.get_records(
hostname,
uri_options[:srv_service_name] || options[:srv_service_name],
uri_options[:srv_max_hosts] || options[:srv_max_hosts]
)
if srv_result.empty?
raise Error::NoSRVRecords.new(NO_SRV_RECORDS % hostname)
end
Expand Down
Loading
Loading