Skip to content

Commit 7e0dc9a

Browse files
committed
[CLIENT] Adds Typhoeus 1.4, now compatible with Faraday 1.0
1 parent 1e1992b commit 7e0dc9a

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

elasticsearch-transport/elasticsearch-transport.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Gem::Specification.new do |s|
6767
s.add_development_dependency 'pry'
6868
s.add_development_dependency 'shoulda-context'
6969
s.add_development_dependency 'test-unit', '~> 2'
70-
s.add_development_dependency 'typhoeus', '~> 0.6'
70+
s.add_development_dependency 'typhoeus', '~> 1.4'
7171
s.add_development_dependency 'yard'
7272
s.add_development_dependency 'bundler'
7373

elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@
240240
end
241241
end
242242

243-
context 'when the adapter is specified' do
244-
243+
context 'when the adapter is patron' do
245244
let(:adapter) do
246245
client.transport.connections.all.first.connection.builder.adapter
247246
end
@@ -255,8 +254,21 @@
255254
end
256255
end
257256

258-
context 'when the adapter is specified as a string key' do
257+
context 'when the adapter is typhoeus' do
258+
let(:adapter) do
259+
client.transport.connections.all.first.connection.builder.adapter
260+
end
261+
262+
let(:client) do
263+
described_class.new(adapter: :typhoeus)
264+
end
265+
266+
it 'uses Faraday with the adapter' do
267+
expect(adapter).to eq Faraday::Adapter::Typhoeus
268+
end
269+
end
259270

271+
context 'when the adapter is specified as a string key' do
260272
let(:adapter) do
261273
client.transport.connections.all.first.connection.builder.adapter
262274
end
@@ -1629,6 +1641,33 @@
16291641
expect(connections_after).to be >= (connections_before)
16301642
end
16311643
end
1644+
1645+
context 'when typhoeus is used as an adapter', unless: jruby? do
1646+
before do
1647+
require 'typhoeus'
1648+
end
1649+
1650+
let(:options) do
1651+
{ adapter: :typhoeus }
1652+
end
1653+
1654+
let(:adapter) do
1655+
client.transport.connections.first.connection.builder.adapter
1656+
end
1657+
1658+
it 'uses the patron connection handler' do
1659+
expect(adapter).to eq('Faraday::Adapter::Typhoeus')
1660+
end
1661+
1662+
it 'keeps connections open' do
1663+
response = client.perform_request('GET', '_nodes/stats/http')
1664+
connections_before = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened']
1665+
client.transport.reload_connections!
1666+
response = client.perform_request('GET', '_nodes/stats/http')
1667+
connections_after = response.body['nodes'].values.find { |n| n['name'] == node_names.first }['http']['total_opened']
1668+
expect(connections_after).to be >= (connections_before)
1669+
end
1670+
end
16321671
end
16331672
end
16341673
end

0 commit comments

Comments
 (0)