Skip to content

Commit

Permalink
Use typhoeus.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Feb 6, 2025
1 parent 85c437a commit 95ab937
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if ENV.key?('FARADAY_VERSION')
gem 'httpclient'
gem 'net-http-persistent'
gem 'patron' unless defined? JRUBY_VERSION
gem 'typhoeus'
gem 'typhoeus', '~> 1.4'
else
gem 'faraday-httpclient'
gem 'faraday-net_http_persistent'
Expand Down
23 changes: 14 additions & 9 deletions spec/opensearch/transport/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1762,48 +1762,53 @@
end
end

context 'when patron is used as an adapter', unless: jruby? do
context 'when typhoeus is used as an adapter', unless: jruby? do
before do
require 'patron'
require 'typhoeus'
end

let(:options) do
{ adapter: :patron }
{ adapter: :typhoeus }
end

let(:adapter) do
client.transport.connections.first.connection.builder.adapter
end

it 'uses the patron connection handler' do
expect(adapter).to eq('Faraday::Adapter::Patron')
it 'uses the typhoeus connection handler' do
expect(adapter).to eq('Faraday::Adapter::Typhoeus')
end

it 'keeps connections open' do
puts 'Testing with _cat/health'
puts client.perform_request('GET', '_cat/health')
puts 'Performing GET _nodes/stats/http'
response = client.perform_request('GET', '_nodes/stats/http')
connections_before = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened']
puts 'Start reloading connections'
client.transport.reload_connections!
puts 'Connections reloaded'
response = client.perform_request('GET', '_nodes/stats/http')
connections_after = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened']
expect(connections_after).to be >= (connections_before)
end
end

context 'when typhoeus is used as an adapter', unless: jruby? do
context 'when patron is used as an adapter', unless: jruby? do
before do
require 'typhoeus'
require 'patron'
end

let(:options) do
{ adapter: :typhoeus }
{ adapter: :patron }
end

let(:adapter) do
client.transport.connections.first.connection.builder.adapter
end

it 'uses the patron connection handler' do
expect(adapter).to eq('Faraday::Adapter::Typhoeus')
expect(adapter).to eq('Faraday::Adapter::Patron')
end

it 'keeps connections open' do
Expand Down

0 comments on commit 95ab937

Please sign in to comment.