logstash-output-jdbc/scripts/minutes_to_retries.rb

21 lines
410 B
Ruby
Raw Normal View History

2016-05-17 10:29:49 +00:00
#!/usr/bin/env ruby -w
seconds_to_reach = 10 * 60
default_interval = 2
retry_max_interval = 128
current_interval = 2
total_interval = 0
exceptions_count = 1
loop do
break if total_interval > seconds_to_reach
exceptions_count += 1
current_interval = current_interval*2 > retry_max_interval ? retry_max_interval : current_interval*2
total_interval += current_interval
end
puts exceptions_count