Class: Elasticsearch::Transport::Transport::HTTP::Manticore

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/elasticsearch/transport/transport/http/manticore.rb

Overview

Alternative HTTP transport implementation for JRuby, using the [Manticore](github.com/cheald/manticore) client,

Examples:


require 'elasticsearch/transport/transport/http/manticore'

client = Elasticsearch::Client.new transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore

client.transport.connections.first.connection
=> #<Manticore::Client:0x56bf7ca6 ...>

client.info['status']
=> 200

See Also:

Constant Summary

Constants included from Base

Base::DEFAULT_MAX_RETRIES, Base::DEFAULT_PORT, Base::DEFAULT_PROTOCOL, Base::DEFAULT_RELOAD_AFTER, Base::DEFAULT_RESURRECT_AFTER, Base::DEFAULT_SERIALIZER_CLASS

Instance Attribute Summary

Attributes included from Base

#connections, #counter, #hosts, #last_request_at, #logger, #max_retries, #options, #protocol, #reload_after, #resurrect_after, #serializer, #sniffer, #tracer

Instance Method Summary collapse

Methods included from Base

#__convert_to_json, #__full_url, #__log, #__log_failed, #__raise_transport_error, #__rebuild_connections, #__trace, #get_connection, #initialize, #reload_connections!, #resurrect_dead_connections!

Instance Method Details

#__build_connectionsConnections::Collection

Builds and returns a collection of connections. Each connection is a Manticore::Client



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/elasticsearch/transport/transport/http/manticore.rb', line 59

def __build_connections
  @request_options = {}

  if options.key?(:headers)
    @request_options[:headers] = options[:headers]
  end

  client_options = setup_ssl(options[:ssl] || {})

  Connections::Collection.new \
    :connections => hosts.map { |host|
      host[:protocol]   = host[:scheme] || DEFAULT_PROTOCOL
      host[:port]     ||= DEFAULT_PORT

      host.delete(:user)     # auth is not supported here.
      host.delete(:password) # use the headers

      url               = __full_url(host)

      Connections::Connection.new \
        :host => host,
        :connection => ::Manticore::Client.new(:options => client_options)
    },
    :selector_class => options[:selector_class],
    :selector => options[:selector]
end

#host_unreachable_exceptionsArray

Returns an array of implementation specific connection errors.

Returns:

  • (Array)


90
91
92
93
94
95
96
97
# File 'lib/elasticsearch/transport/transport/http/manticore.rb', line 90

def host_unreachable_exceptions
  [
    ::Manticore::Timeout,
    ::Manticore::SocketException,
    ::Manticore::ClientProtocolException,
    ::Manticore::ResolutionFailure
  ]
end

#perform_request(method, path, params = {}, body = nil) ⇒ Response

Performs the request by invoking Base#perform_request with a block.

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/elasticsearch/transport/transport/http/manticore.rb', line 32

def perform_request(method, path, params={}, body=nil)
  super do |connection, url|
    params[:body] = __convert_to_json(body) if body
    params = params.merge @request_options
    case method
    when "GET"
      resp = connection.connection.get(url, params)
    when "HEAD"
      resp = connection.connection.head(url, params)
    when "PUT"
      resp = connection.connection.put(url, params)
    when "POST"
      resp = connection.connection.post(url, params)
    when "DELETE"
      resp = connection.connection.delete(url, params)
    else
      raise ArgumentError.new "Method #{method} not supported"
    end
    Response.new resp.code, resp.read_body, resp.headers
  end
end