Class: Elasticsearch::Transport::Transport::HTTP::AWS
- Inherits:
-
Object
- Object
- Elasticsearch::Transport::Transport::HTTP::AWS
- Includes:
- Base
- Defined in:
- lib/elasticsearch/transport/transport/http/aws.rb
Overview
Transport implementation, which V4 Signs requests using the [Faraday](rubygems.org/gems/faraday) library for abstracting the HTTP client.
Defined Under Namespace
Classes: CredentialConfig
Constant Summary collapse
- DEFAULT_PORT =
80- DEFAULT_PROTOCOL =
"http"
Instance Method Summary collapse
-
#__build_connections ⇒ Connections::Collection
Builds and returns a collection of connections.
-
#host_unreachable_exceptions ⇒ Array
Returns an array of implementation specific connection errors.
-
#perform_request(method, path, params = {}, body = nil) ⇒ Response
Performs the request by invoking Transport::Base#perform_request with a block.
Instance Method Details
#__build_connections ⇒ Connections::Collection
Builds and returns a collection of connections.
55 56 57 58 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 85 |
# File 'lib/elasticsearch/transport/transport/http/aws.rb', line 55 def __build_connections region = [:region] access_key_id = [:aws_access_key_id] || nil secret_access_key = [:aws_secret_access_key] || nil session_token = [:session_token] || nil profile = [:profile] || 'default' credential_config = CredentialConfig.new(access_key_id, secret_access_key, session_token, profile) credentials = Aws::CredentialProviderChain.new(credential_config).resolve Connections::Collection.new \ connections: hosts.map { |host| host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL host[:port] ||= DEFAULT_PORT url = __full_url(host) aes_connection = ::Faraday.new(url, ([:transport_options] || {})) do |faraday| faraday.request :aws_v4_signer, credentials: credentials, service_name: 'es', region: region faraday.adapter :net_http end Connections::Connection.new \ host: host, connection: aes_connection }, selector_class: [:selector_class], selector: [:selector] end |
#host_unreachable_exceptions ⇒ Array
Returns an array of implementation specific connection errors.
91 92 93 |
# File 'lib/elasticsearch/transport/transport/http/aws.rb', line 91 def host_unreachable_exceptions [::Faraday::Error::ConnectionFailed, ::Faraday::Error::TimeoutError] end |
#perform_request(method, path, params = {}, body = nil) ⇒ Response
Performs the request by invoking Transport::Base#perform_request with a block.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/elasticsearch/transport/transport/http/aws.rb', line 39 def perform_request(method, path, params={}, body=nil) super do |connection, url| response = connection.connection.run_request \ method.downcase.to_sym, url, ( body ? __convert_to_json(body) : nil ), {} Response.new response.status, response.body, response.headers end end |