class Elasticsearch::Transport::Transport::Connections::Selector::RoundRobin
“Round-robin” selector strategy (default).
Public Class Methods
new(arguments = {})
click to toggle source
@option arguments [Connections::Collection] :connections Collection with connections.
Calls superclass method
# File lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_connections_selector.rb, line 24 def initialize(arguments = {}) super @mutex = Mutex.new @current = nil end
Public Instance Methods
select(options={})
click to toggle source
Returns the next connection from the collection, rotating them in round-robin fashion.
@return [Connections::Connection]
# File lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_connections_selector.rb, line 34 def select(options={}) @mutex.synchronize do conns = connections if @current && (@current < conns.size-1) @current += 1 else @current = 0 end conns[@current] end end