Class: Elasticsearch::Transport::Transport::Connections::Selector::RoundRobin
- Inherits:
-
Object
- Object
- Elasticsearch::Transport::Transport::Connections::Selector::RoundRobin
- Includes:
- Base
- Defined in:
- lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_connections_selector.rb
Overview
“Round-robin” selector strategy (default).
Instance Method Summary collapse
-
#initialize(arguments = {}) ⇒ RoundRobin
constructor
A new instance of RoundRobin.
-
#select(options = {}) ⇒ Connections::Connection
Returns the next connection from the collection, rotating them in round-robin fashion.
Constructor Details
#initialize(arguments = {}) ⇒ RoundRobin
Returns a new instance of RoundRobin.
24 25 26 27 28 |
# File 'lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_connections_selector.rb', line 24 def initialize(arguments = {}) super @mutex = Mutex.new @current = nil end |
Instance Method Details
#select(options = {}) ⇒ Connections::Connection
Returns the next connection from the collection, rotating them in round-robin fashion.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_connections_selector.rb', line 34 def select(={}) @mutex.synchronize do conns = connections if @current && (@current < conns.size-1) @current += 1 else @current = 0 end conns[@current] end end |