mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
move logic around loop counts to a more reasonable location
This commit is contained in:
@@ -125,8 +125,6 @@ module Suo
|
|||||||
|
|
||||||
fail "Client required" unless options[:client]
|
fail "Client required" unless options[:client]
|
||||||
|
|
||||||
options[:retry_count] = (options[:retry_timeout] / options[:retry_delay].to_f).ceil
|
|
||||||
|
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -149,13 +147,13 @@ module Suo
|
|||||||
end
|
end
|
||||||
|
|
||||||
def retry_with_timeout(key, options)
|
def retry_with_timeout(key, options)
|
||||||
|
count = (options[:retry_timeout] / options[:retry_delay].to_f).ceil
|
||||||
|
|
||||||
start = Time.now.to_f
|
start = Time.now.to_f
|
||||||
|
|
||||||
options[:retry_count].times do
|
count.times do
|
||||||
if options[:retry_timeout]
|
|
||||||
now = Time.now.to_f
|
now = Time.now.to_f
|
||||||
break if now - start > options[:retry_timeout]
|
break if now - start > options[:retry_timeout]
|
||||||
end
|
|
||||||
|
|
||||||
synchronize(key, options) do
|
synchronize(key, options) do
|
||||||
yield
|
yield
|
||||||
|
|||||||
Reference in New Issue
Block a user