move logic around loop counts to a more reasonable location

This commit is contained in:
Nick Elser
2015-04-12 20:57:29 -07:00
parent 1aacc0c1a1
commit 8d7ddaf35a

View File

@@ -125,8 +125,6 @@ module Suo
fail "Client required" unless options[:client]
options[:retry_count] = (options[:retry_timeout] / options[:retry_delay].to_f).ceil
options
end
@@ -149,13 +147,13 @@ module Suo
end
def retry_with_timeout(key, options)
count = (options[:retry_timeout] / options[:retry_delay].to_f).ceil
start = Time.now.to_f
options[:retry_count].times do
if options[:retry_timeout]
now = Time.now.to_f
break if now - start > options[:retry_timeout]
end
count.times do
now = Time.now.to_f
break if now - start > options[:retry_timeout]
synchronize(key, options) do
yield