Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for configuration keys with nil values to fall back onto defaults #627

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/redis/client.rb
Expand Up @@ -86,7 +86,7 @@ def initialize(options = {})

@pending_reads = 0

if options.include?(:sentinels)
if options.include?(:sentinels) && options[:sentinels].any? { |conf| !conf[:host].nil? && !conf[:port].nil? }
@connector = Connector::Sentinel.new(@options)
else
@connector = Connector.new(@options)
Expand Down Expand Up @@ -331,7 +331,7 @@ def establish_connection
server = @connector.resolve.dup

@options[:host] = server[:host]
@options[:port] = Integer(server[:port]) if server.include?(:port)
@options[:port] = Integer(server[:port]) if server.include?(:port) && !server[:port].nil?

@connection = @options[:driver].connect(@options)
@pending_reads = 0
Expand Down Expand Up @@ -435,7 +435,7 @@ def _parse_options(options)
options[:port] = options[:port].to_i
end

if options.has_key?(:timeout)
if options.has_key?(:timeout) && !options[:timeout].nil?
options[:connect_timeout] ||= options[:timeout]
options[:read_timeout] ||= options[:timeout]
options[:write_timeout] ||= options[:timeout]
Expand Down Expand Up @@ -508,7 +508,7 @@ def initialize(options)
@options[:db] = DEFAULTS.fetch(:db)

@sentinels = @options.delete(:sentinels).dup
@role = @options.fetch(:role, "master").to_s
@role = (@options[:role] || "master").to_s
@master = @options[:host]
end

Expand Down