elasticsearch-transport 7.6.0 → 7.7.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +58 -22
- data/elasticsearch-transport.gemspec +1 -1
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/spec/elasticsearch/transport/client_spec.rb +13 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 514552f2ef4e92c8ba16f376cbe452963c62e79afcb4feba64ff62a9562d9463
|
4
|
+
data.tar.gz: 48dabfa3c58ab1aa80af7c1fe5b487582c46f8822f7fec6816f67da16f11959e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97084b1748a5043dbef690c1d946e893a7a4d565d149e1369d70eacbce18cb9ce0fda5c450cc113acce6beaf09701173d8f9d08f0186e028677ef5e2f84fa647
|
7
|
+
data.tar.gz: e58a5aa7a30cc7a282649bb87cc957f25a33b98b1ca8554c157ee855b52af81b4247da82ac7d3ecffaef78b3a9fc3b6584258ba3f0e63000d59c4c95a9f8280c
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ Currently these libraries will be automatically detected and used:
|
|
37
37
|
- [HTTPClient](https://rubygems.org/gems/httpclient)
|
38
38
|
- [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent)
|
39
39
|
|
40
|
-
**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.
|
40
|
+
**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
|
41
41
|
|
42
42
|
For detailed information, see example configurations [below](#transport-implementations).
|
43
43
|
|
@@ -78,6 +78,7 @@ Full documentation is available at <http://rubydoc.info/gems/elasticsearch-trans
|
|
78
78
|
* [Connect using an Elastic Cloud ID](#connect-using-an-elastic-cloud-id)
|
79
79
|
* [Authentication](#authentication)
|
80
80
|
* [Logging](#logging)
|
81
|
+
* [Custom HTTP Headers](#custom-http-headers)
|
81
82
|
* [Identifying running tasks with X-Opaque-Id](#identifying-running-tasks-with-x-opaque-id)
|
82
83
|
* [Setting Timeouts](#setting-timeouts)
|
83
84
|
* [Randomizing Hosts](#randomizing-hosts)
|
@@ -189,30 +190,61 @@ Elasticsearch::Client.new(
|
|
189
190
|
To log requests and responses to standard output with the default logger (an instance of Ruby's {::Logger} class),
|
190
191
|
set the `log` argument:
|
191
192
|
|
192
|
-
|
193
|
+
```ruby
|
194
|
+
Elasticsearch::Client.new log: true
|
195
|
+
```
|
196
|
+
|
193
197
|
|
194
198
|
To trace requests and responses in the _Curl_ format, set the `trace` argument:
|
195
199
|
|
196
|
-
|
200
|
+
```ruby
|
201
|
+
Elasticsearch::Client.new trace: true
|
202
|
+
```
|
197
203
|
|
198
204
|
You can customize the default logger or tracer:
|
199
205
|
|
206
|
+
```ruby
|
200
207
|
client.transport.logger.formatter = proc { |s, d, p, m| "#{s}: #{m}\n" }
|
201
208
|
client.transport.logger.level = Logger::INFO
|
209
|
+
```
|
202
210
|
|
203
211
|
Or, you can use a custom `::Logger` instance:
|
204
212
|
|
205
|
-
|
213
|
+
```ruby
|
214
|
+
Elasticsearch::Client.new logger: Logger.new(STDERR)
|
215
|
+
```
|
206
216
|
|
207
217
|
You can pass the client any conforming logger implementation:
|
208
218
|
|
209
|
-
|
219
|
+
```ruby
|
220
|
+
require 'logging' # https://github.com/TwP/logging/
|
221
|
+
|
222
|
+
log = Logging.logger['elasticsearch']
|
223
|
+
log.add_appenders Logging.appenders.stdout
|
224
|
+
log.level = :info
|
225
|
+
|
226
|
+
client = Elasticsearch::Client.new logger: log
|
227
|
+
```
|
210
228
|
|
211
|
-
|
212
|
-
|
213
|
-
|
229
|
+
### Custom HTTP Headers
|
230
|
+
|
231
|
+
You can set a custom HTTP header on the client's initializer:
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
client = Elasticsearch::Client.new(
|
235
|
+
transport_options: {
|
236
|
+
headers:
|
237
|
+
{user_agent: "My App"}
|
238
|
+
}
|
239
|
+
)
|
240
|
+
```
|
241
|
+
|
242
|
+
You can also pass in `headers` as a parameter to any of the API Endpoints to set custom headers for the request:
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
client.search(index: 'myindex', q: 'title:test', headers: {user_agent: "My App"})
|
246
|
+
```
|
214
247
|
|
215
|
-
client = Elasticsearch::Client.new logger: log
|
216
248
|
### Identifying running tasks with X-Opaque-Id
|
217
249
|
|
218
250
|
The X-Opaque-Id header allows to track certain calls, or associate certain tasks with the client that started them ([more on the Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html#_identifying_running_tasks)). To use this feature, you need to set an id for `opaque_id` on the client on each request. Example:
|
@@ -330,25 +362,29 @@ preferring HTTP clients with support for persistent connections.
|
|
330
362
|
|
331
363
|
To use the [_Patron_](https://github.com/toland/patron) HTTP, for example, just require it:
|
332
364
|
|
333
|
-
|
365
|
+
```ruby
|
366
|
+
require 'patron'
|
367
|
+
```
|
334
368
|
|
335
369
|
Then, create a new client, and the _Patron_ gem will be used as the "driver":
|
336
370
|
|
337
|
-
|
371
|
+
```ruby
|
372
|
+
client = Elasticsearch::Client.new
|
338
373
|
|
339
|
-
|
340
|
-
|
374
|
+
client.transport.connections.first.connection.builder.adapter
|
375
|
+
# => Faraday::Adapter::Patron
|
341
376
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
377
|
+
10.times do
|
378
|
+
client.nodes.stats(metric: 'http')['nodes'].values.each do |n|
|
379
|
+
puts "#{n['name']} : #{n['http']['total_opened']}"
|
380
|
+
end
|
381
|
+
end
|
347
382
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
383
|
+
# => Stiletoo : 24
|
384
|
+
# => Stiletoo : 24
|
385
|
+
# => Stiletoo : 24
|
386
|
+
# => ...
|
387
|
+
```
|
352
388
|
|
353
389
|
To use a specific adapter for _Faraday_, pass it as the `adapter` argument:
|
354
390
|
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency 'elasticsearch-extensions'
|
35
35
|
s.add_development_dependency 'minitest'
|
36
36
|
s.add_development_dependency 'minitest-reporters'
|
37
|
-
s.add_development_dependency 'rake', '~>
|
37
|
+
s.add_development_dependency 'rake', '~> 13'
|
38
38
|
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
39
39
|
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
40
40
|
s.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
|
@@ -1129,10 +1129,22 @@ describe Elasticsearch::Transport::Client do
|
|
1129
1129
|
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
1130
1130
|
expect { client.search(opaque_id: 'opaque_id') }.not_to raise_error
|
1131
1131
|
expect(client).to have_received(:perform_request)
|
1132
|
-
.with('GET', '_search', { opaque_id: 'opaque_id' }, nil)
|
1132
|
+
.with('GET', '_search', { opaque_id: 'opaque_id' }, nil, {})
|
1133
1133
|
end
|
1134
1134
|
end
|
1135
1135
|
end
|
1136
|
+
|
1137
|
+
context 'when a header is set on an endpoint request' do
|
1138
|
+
let(:client) { described_class.new(host: hosts) }
|
1139
|
+
let(:headers) { { 'user-agent' => 'my ruby app' } }
|
1140
|
+
|
1141
|
+
it 'performs the request with the header' do
|
1142
|
+
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
1143
|
+
expect { client.search(headers: headers) }.not_to raise_error
|
1144
|
+
expect(client).to have_received(:perform_request)
|
1145
|
+
.with('GET', '_search', {}, nil, headers)
|
1146
|
+
end
|
1147
|
+
end
|
1136
1148
|
end
|
1137
1149
|
|
1138
1150
|
context 'when the client connects to Elasticsearch' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.7.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '13'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '13'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: require-prof
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -419,9 +419,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
419
419
|
version: '2.4'
|
420
420
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
421
421
|
requirements:
|
422
|
-
- - "
|
422
|
+
- - ">"
|
423
423
|
- !ruby/object:Gem::Version
|
424
|
-
version:
|
424
|
+
version: 1.3.1
|
425
425
|
requirements: []
|
426
426
|
rubygems_version: 3.1.2
|
427
427
|
signing_key:
|