Skip to content

Commit ca417b6

Browse files
committed
[Client] Change how the adapter is set in the client initializer
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.
1 parent a0954bb commit ca417b6

File tree

1 file changed

+2
-4
lines changed
  • elasticsearch-transport/lib/elasticsearch/transport

1 file changed

+2
-4
lines changed

elasticsearch-transport/lib/elasticsearch/transport/client.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ def initialize(arguments={}, &block)
142142
transport_class = @arguments[:transport_class] || DEFAULT_TRANSPORT_CLASS
143143
if transport_class == Transport::HTTP::Faraday
144144
@transport = transport_class.new(hosts: @seeds, options: @arguments) do |faraday|
145-
block.call faraday if block
146-
unless (h = faraday.builder.handlers.last) && h.name.start_with?("Faraday::Adapter")
147-
faraday.adapter(@arguments[:adapter] || __auto_detect_adapter)
148-
end
145+
faraday.adapter(@arguments[:adapter] || __auto_detect_adapter)
146+
block&.call faraday
149147
end
150148
else
151149
@transport = transport_class.new(hosts: @seeds, options: @arguments)

0 commit comments

Comments
 (0)