class OpenSearch::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
OpenSearch::Transport::Transport::Connections::Selector::Base::new
# File lib/opensearch/transport/transport/connections/selector.rb, line 75 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/opensearch/transport/transport/connections/selector.rb, line 85 def select(options={}) @mutex.synchronize do conns = connections if @current && (@current < conns.size-1) @current += 1 else @current = 0 end conns[@current] end end