lib/syslogstash/logstash_writer.rb in syslogstash-1.2.1 vs lib/syslogstash/logstash_writer.rb in syslogstash-1.3.0
- old
+ new
@@ -102,13 +102,12 @@
@current_server = nil
sleep 0.1
end
else
begin
- # Rotate the next server onto the back of the list
- next_server = @servers.shift
+ # Pick another server to connect to at random
+ next_server = @servers.sort { rand }.first
debug { "Trying to connect to #{next_server.to_s}" }
- @servers.push(next_server)
@current_server = TCPSocket.new(next_server.hostname, next_server.port)
rescue SystemCallError => ex
# Connection failed for any number of reasons; try again
debug { "Failed to connect to #{next_server.to_s}: #{ex.message} (#{ex.class})" }
sleep 0.1