Class: Elastictastic::Rotor
- Inherits:
-
Object
- Object
- Elastictastic::Rotor
- Includes:
- TransportMethods
- Defined in:
- lib/elastictastic/rotor.rb
Defined Under Namespace
Classes: Node
Constant Summary collapse
Class.new(StandardError)
Instance Method Summary collapse
-
#initialize(hosts, options) ⇒ Rotor
constructor
A new instance of Rotor.
- #request(method, path, body = nil) ⇒ Object
Methods included from TransportMethods
#delete, #get, #head, #post, #put
Constructor Details
#initialize(hosts, options) ⇒ Rotor
Returns a new instance of Rotor.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/elastictastic/rotor.rb', line 11 def initialize(hosts, ) = {} [:backoff_threshold, :backoff_start, :backoff_max].each do |key| [key] = .delete(key) end adapter = Adapter[.delete(:adapter)] @connections = hosts.map do |host| Node.new(adapter.new(host, ), ) end @head_index = 0 end |
Instance Method Details
#request(method, path, body = nil) ⇒ Object
23 24 25 |
# File 'lib/elastictastic/rotor.rb', line 23 def request(method, path, body = nil) try_rotate { |node| node.request(method, path, body) } end |