Skip to content

Commit

Permalink
Update READMES
Browse files Browse the repository at this point in the history
  • Loading branch information
picandocodigo committed Mar 26, 2020
1 parent f6fcb76 commit 1b18df2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
47 changes: 26 additions & 21 deletions elasticsearch-transport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -366,34 +370,35 @@ 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.

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:

Expand Down

0 comments on commit 1b18df2

Please # to comment.