Module: Noiseless::Adapters::ExecutionModules::HttpTransport
- Included in:
- EsCompatibleExecution, TypesenseExecution
- Defined in:
- lib/noiseless/adapters/execution_modules/http_transport.rb
Overview
Shared Async::HTTP connection handling for HTTP-based adapters. Host classes must provide a private default_port method.
Constant Summary collapse
- TRANSPORT_ERRORS =
Low-level failures the Async::HTTP stack raises when it cannot complete a round-trip with the backend (refused/reset connection, DNS failure, transport timeout). These are wrapped into Noiseless::ConnectionError so callers never have to know which HTTP stack is underneath.
[SystemCallError, SocketError, IOError, Timeout::Error].freeze
Instance Method Summary collapse
Instance Method Details
#close ⇒ Object
34 35 36 |
# File 'lib/noiseless/adapters/execution_modules/http_transport.rb', line 34 def close @clients&.each_value(&:close) end |
#initialize(hosts: [], **connection_params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/noiseless/adapters/execution_modules/http_transport.rb', line 18 def initialize(hosts: [], **connection_params) # Ensure we always have at least one host hosts_array = Array(hosts) @hosts = hosts_array.empty? ? ["http://localhost:#{default_port}"] : hosts_array @connection_params = connection_params # Initialize HTTP clients for each host @clients = {} @hosts.each do |host| endpoint = Async::HTTP::Endpoint.parse(host) @clients[host] = Async::HTTP::Client.new(endpoint) end super(hosts: @hosts, **connection_params) end |