Class: OpenSearch::Transport::Transport::HTTP::Faraday
- Inherits:
-
Object
- Object
- OpenSearch::Transport::Transport::HTTP::Faraday
- Includes:
- Base
- Defined in:
- lib/opensearch/transport/transport/http/faraday.rb
Overview
The default transport implementation, using the [Faraday](rubygems.org/gems/faraday) library for abstracting the HTTP client.
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, Base::SANITIZED_PASSWORD
Instance Attribute Summary
Attributes included from Base
#connections, #counter, #hosts, #last_request_at, #logger, #options, #protocol, #reload_after, #reload_connections, #resurrect_after, #serializer, #sniffer, #tracer
Instance Method Summary collapse
-
#__build_connection(host, options = {}, block = nil) ⇒ Connections::Connection
Builds and returns a connection.
-
#host_unreachable_exceptions ⇒ Array
Returns an array of implementation specific connection errors.
-
#perform_request(method, path, params = {}, body = nil, headers = nil, opts = {}) ⇒ Response
Performs the request by invoking Base#perform_request with a block.
Methods included from Base
#__build_connections, #__close_connections, #__convert_to_json, #__full_url, #__log_response, #__raise_transport_error, #__rebuild_connections, #__trace, #get_connection, #initialize, #reload_connections!, #resurrect_dead_connections!
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Instance Method Details
#__build_connection(host, options = {}, block = nil) ⇒ Connections::Connection
Builds and returns a connection
71 72 73 74 75 |
# File 'lib/opensearch/transport/transport/http/faraday.rb', line 71 def __build_connection(host, = {}, block = nil) client = ::Faraday.new(__full_url(host), , &block) apply_headers(client, ) Connections::Connection.new host: host, connection: client end |
#host_unreachable_exceptions ⇒ Array
Returns an array of implementation specific connection errors.
81 82 83 |
# File 'lib/opensearch/transport/transport/http/faraday.rb', line 81 def host_unreachable_exceptions [::Faraday::ConnectionFailed, ::Faraday::TimeoutError] end |
#perform_request(method, path, params = {}, body = nil, headers = nil, opts = {}) ⇒ Response
Performs the request by invoking Base#perform_request with a block.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/opensearch/transport/transport/http/faraday.rb', line 44 def perform_request(method, path, params = {}, body = nil, headers = nil, opts = {}) super do |connection, url| headers = if connection.connection.headers if headers.nil? connection.connection.headers else connection.connection.headers.merge(headers) end else headers end response = connection.connection.run_request( method.downcase.to_sym, url, (body ? __convert_to_json(body) : nil), headers ) Response.new response.status, decompress_response(response.body), response.headers end end |