Skip to content

Commit

Permalink
[Client] Change how the adapter is set in the client initializer
Browse files Browse the repository at this point in the history
Migrating to Faraday 1.0 means we check with `adapter` to see which one has been
selected. I also changed the order in which the given block is ran. There's a
case where one of the adapter libraries could be loaded and an adapter is passed
in with the block, but `__auto_detect_adapter` would overwrite this. So the
block is now ran last.
  • Loading branch information
picandocodigo committed Mar 25, 2020
1 parent 293cbfc commit 0fdc653
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions elasticsearch-transport/lib/elasticsearch/transport/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,8 @@ def initialize(arguments={}, &block)
transport_class = @arguments[:transport_class] || DEFAULT_TRANSPORT_CLASS
if transport_class == Transport::HTTP::Faraday
@transport = transport_class.new(hosts: @seeds, options: @arguments) do |faraday|
block.call faraday if block
unless (h = faraday.builder.handlers.last) && h.name.start_with?("Faraday::Adapter")
faraday.adapter(@arguments[:adapter] || __auto_detect_adapter)
end
faraday.adapter(@arguments[:adapter] || __auto_detect_adapter)
block&.call faraday
end
else
@transport = transport_class.new(hosts: @seeds, options: @arguments)
Expand Down

0 comments on commit 0fdc653

Please # to comment.