lib/redis_cluster/client.rb in redis_cluster-0.2.3 vs lib/redis_cluster/client.rb in redis_cluster-0.2.4
- old
+ new
@@ -9,19 +9,19 @@
@pool = Pool.new
@mutex = Mutex.new
reload_pool_nodes
end
- def execute(method, args)
+ def execute(method, args, &block)
ttl = Configuration::REQUEST_TTL
asking = false
try_random_node = false
while ttl > 0
ttl -= 1
begin
- return @pool.execute(method, args, {asking: asking, random_node: try_random_node})
+ return @pool.execute(method, args, {asking: asking, random_node: try_random_node}, &block)
rescue Errno::ECONNREFUSED, Redis::TimeoutError, Redis::CannotConnectError, Errno::EACCES
try_random_node = true
sleep 0.1 if ttl < Configuration::REQUEST_TTL/2
rescue => e
err_code = e.to_s.split.first
@@ -36,16 +36,16 @@
end
end
end
Configuration::SUPPORT_SINGLE_NODE_METHODS.each do |method_name|
- define_method method_name do |*args|
- execute(method_name, args)
+ define_method method_name do |*args, &block|
+ execute(method_name, args, &block)
end
end
def method_missing(method, *args, &block)
- execute(method, args)
+ execute(method, args, &block)
end
private
def reload_pool_nodes