From 1b18df27f3192aae5c0545b228c71959572fdf24 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 25 Mar 2020 21:37:29 +0000 Subject: [PATCH] Update READMES --- README.md | 4 +-- elasticsearch-transport/README.md | 47 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 753a541e5e..4bfcc2d744 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,7 @@ Both of these libraries are extensively documented. and the [`elasticsearch-api`](http://rubydoc.info/gems/elasticsearch-api) documentation carefully.** _Keep in mind, that 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)._ These libraries are not dependencies of the elasticsearch gems, so -be sure to define a dependency in your own application. +("keep-alive") connections, e.g. [Patron](https://github.com/toland/patron)._ These libraries are not dependencies of the elasticsearch gems, so be sure to define a dependency in your own application. This repository contains these additional Ruby libraries: diff --git a/elasticsearch-transport/README.md b/elasticsearch-transport/README.md index 9cff86669d..985ed435bb 100644 --- a/elasticsearch-transport/README.md +++ b/elasticsearch-transport/README.md @@ -28,12 +28,16 @@ Features overview: * Node reloading (based on cluster state) on errors or on demand For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections, -such as [Typhoeus](https://github.com/typhoeus/typhoeus). -Just require the library (`require 'typhoeus'; require 'typhoeus/adapters/faraday'`) in your code, -and it will be automatically used; currently these libraries will be automatically detected and used: -[Patron](https://github.com/toland/patron), -[HTTPClient](https://rubygems.org/gems/httpclient) and -[Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent). +such as [patron](https://github.com/toland/patron). +Just require the library (`require 'patron'`) in your code, +and it will be automatically used. + +Currently these libraries will be automatically detected and used: +- [Patron](https://github.com/toland/patron) +- [HTTPClient](https://rubygems.org/gems/httpclient) +- [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent) + +**Note on [Typhoeus](https://github.com/typhoeus/typhoeus)**: Typhoeus is compatible and will be automatically detected too. However, the latest release (v1.3.1 at the moment of writing this) is not compatible with Faraday 1.0. [It still uses the deprecated `Faraday::Error` namespace](https://github.com/typhoeus/typhoeus/blob/v1.3.1/lib/typhoeus/adapters/faraday.rb#L100). If you want to use it with this gem, we suggest getting `master` from GitHub, since this has been fixed for v1.4.0. We'll update this if/when v1.4.0 is released.a For detailed information, see example configurations [below](#transport-implementations). @@ -366,12 +370,11 @@ constructor, use the `transport_options` key: To configure the _Faraday_ instance directly, use a block: - require 'typhoeus' - require 'typhoeus/adapters/faraday' + require 'patron' client = Elasticsearch::Client.new(host: 'localhost', port: '9200') do |f| f.response :logger - f.adapter :typhoeus + f.adapter :patron end You can use any standard Faraday middleware and plugins in the configuration block, for example sign the requests for the [AWS Elasticsearch service](https://aws.amazon.com/elasticsearch-service/). See [the AWS documentation](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html#es-request-signing-ruby) for an example. @@ -379,21 +382,23 @@ You can use any standard Faraday middleware and plugins in the configuration blo You can also initialize the transport class yourself, and pass it to the client constructor as the `transport` argument: - require 'typhoeus' - require 'typhoeus/adapters/faraday' +```ruby +require 'patron' - transport_configuration = lambda do |f| - f.response :logger - f.adapter :typhoeus - end +transport_configuration = lambda do |f| + f.response :logger + f.adapter :patron +end - transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \ - hosts: [ { host: 'localhost', port: '9200' } ], - &transport_configuration +transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \ + hosts: [ { host: 'localhost', port: '9200' } ], + &transport_configuration + +# Pass the transport to the client +# +client = Elasticsearch::Client.new transport: transport +``` - # Pass the transport to the client - # - client = Elasticsearch::Client.new transport: transport Instead of passing the transport to the constructor, you can inject it at run time: