lib/redis_cluster/client.rb in redis_cluster-0.2.5 vs lib/redis_cluster/client.rb in redis_cluster-0.2.6
- old
+ new
@@ -6,11 +6,11 @@
def initialize(startup_hosts, global_configs = {})
@startup_hosts = startup_hosts
@pool = Pool.new
@mutex = Mutex.new
- reload_pool_nodes
+ reload_pool_nodes(true)
end
def execute(method, args, &block)
ttl = Configuration::REQUEST_TTL
asking = false
@@ -47,20 +47,23 @@
execute(method, args, &block)
end
private
- def reload_pool_nodes
+ def reload_pool_nodes(raise_error = false)
@mutex.synchronize do
@startup_hosts.each do |options|
begin
redis = Node.redis(options)
slots_mapping = redis.cluster("slots").group_by{|x| x[2]}
@pool.delete_except!(slots_mapping.keys)
slots_mapping.each do |host, infos|
slots_ranges = infos.map {|x| x[0]..x[1] }
@pool.add_node!({host: host[0], port: host[1]}, slots_ranges)
end
+ rescue Redis::CommandError => e
+ raise e if raise_error && e.message =~ /cluster\ support\ disabled$/
+ next
rescue
next
end
break
end