Skip to content

Instantly share code, notes, and snippets.

@tisba tisba/gist:9913992
Created Apr 1, 2014

Embed
What would you like to do?
def connect_with_retry(&block)
hosts = @hosts.dup
delay = @initial_delay
begin
hosts.push(host = hosts.shift)
http = Net::HTTP.new(host, @port)
http.open_timeout = @open_timeout
http.read_timeout = @read_timeout
http.use_ssl = @use_ssl
block.call(http)
rescue InfluxDB::Error
rescue StandardError => e
log :error, "Failed to contact host #{host}: #{e.inspect} - retrying in #{delay}s."
log :info, "Queue size is #{@queue.length}." unless @queue.nil?
sleep delay
delay = [@max_delay, delay * 2].min
retry
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.