6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/sbmt/outbox/redis_client_factory.rb', line 6
def self.build(options)
options = options.deep_symbolize_keys
unless options.key?(:reconnect_attempts)
options[:reconnect_attempts] = 3
end
if options.key?(:sentinels)
if (url = options.delete(:url))
uri = URI.parse(url)
if !options.key?(:name) && uri.host
options[:name] = uri.host
end
if !options.key?(:password) && uri.password && !uri.password.empty?
options[:password] = uri.password
end
if !options.key?(:username) && uri.user && !uri.user.empty?
options[:username] = uri.user
end
end
RedisClient.sentinel(**options).new_client
else
RedisClient.config(**options).new_client
end
end
|