Class: ElasticSearch::Transport::HTTP
- Defined in:
- lib/elasticsearch/transport/http.rb
Constant Summary collapse
- DEFAULTS =
{ :timeout => 5, :protocol => 'http' }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #all_nodes ⇒ Object
- #connect! ⇒ Object
-
#initialize(server, options = {}) ⇒ HTTP
constructor
A new instance of HTTP.
Methods inherited from Base
Methods included from ClusterAdminProtocol
#cluster_health, #cluster_state, #nodes_info, #nodes_stats, #restart_nodes, #shutdown_nodes
Methods included from IndexAdminProtocol
#alias_index, #create_index, #create_river, #delete_index, #delete_mapping, #delete_river, #flush, #get_aliases, #get_river, #get_settings, #index_mapping, #index_status, #optimize, #refresh, #river_status, #snapshot, #update_mapping, #update_settings
Methods included from IndexProtocol
#bulk, #count, #delete, #delete_by_query, #get, #index, #multi_get, #scroll, #search
Constructor Details
#initialize(server, options = {}) ⇒ HTTP
Returns a new instance of HTTP.
12 13 14 15 16 17 18 19 20 |
# File 'lib/elasticsearch/transport/http.rb', line 12 def initialize(server, ={}) super @options = DEFAULTS.merge(@options) # Make sure the server starts with a URI scheme. unless @server =~ /^(([^:\/?#]+):)?\/\// @server = "#{@options[:protocol]}://" + @server end end |
Instance Method Details
#all_nodes ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/elasticsearch/transport/http.rb', line 27 def all_nodes http_addresses = nodes_info([])["nodes"].collect { |id, node| node["http_address"] } http_addresses.collect! do |a| if a =~ /inet\[.*\/([\d.:]+)\]/ $1 end end.compact! http_addresses end |
#connect! ⇒ Object
22 23 24 25 |
# File 'lib/elasticsearch/transport/http.rb', line 22 def connect! @session = Excon.new(@server, { :connect_timeout => @options[:timeout], :headers => {'User-Agent' => 'ElasticSearch.rb v0.1'}}) end |