From 34fb0b7363a43da37cf1b1961661e87d4aed92d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janko=20Marohni=C4=87?= Date: Tue, 10 Feb 2015 14:20:23 +0100 Subject: [PATCH] [CLIENT] Make Typhoeus work out of the box --- elasticsearch-transport/README.md | 2 +- elasticsearch-transport/lib/elasticsearch/transport/client.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/elasticsearch-transport/README.md b/elasticsearch-transport/README.md index f0a8748ed1..bbaa0813e0 100644 --- a/elasticsearch-transport/README.md +++ b/elasticsearch-transport/README.md @@ -29,7 +29,7 @@ Features overview: For optimal performance, you should use a HTTP library which supports persistent ("keep-alive") connections, e.g. [Patron](https://github.com/toland/patron) or [Typhoeus](https://github.com/typhoeus/typhoeus). -Just `require 'patron'` or `require 'typhoeus'; require 'typhoeus/adapters/faraday'` in your code, +Just `require 'patron'` or `require 'typhoeus'` in your code, and it will be automatically used; other automatically used libraries are [HTTPClient](https://rubygems.org/gems/httpclient) and [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent). diff --git a/elasticsearch-transport/lib/elasticsearch/transport/client.rb b/elasticsearch-transport/lib/elasticsearch/transport/client.rb index da42030f0e..575f7d8d68 100644 --- a/elasticsearch-transport/lib/elasticsearch/transport/client.rb +++ b/elasticsearch-transport/lib/elasticsearch/transport/client.rb @@ -99,7 +99,9 @@ def initialize(arguments={}) @transport = arguments[:transport] || begin if transport_class == Transport::HTTP::Faraday transport_class.new(:hosts => __extract_hosts(hosts, arguments), :options => arguments) do |faraday| - faraday.adapter(arguments[:adapter] || __auto_detect_adapter) + adapter = arguments[:adapter] || __auto_detect_adapter + require "typhoeus/adapters/faraday" if adapter == :typhoeus + faraday.adapter(adapter) end else transport_class.new(:hosts => __extract_hosts(hosts, arguments), :options => arguments)