elasticsearch-transport 5.0.3 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44170b2419c63a6ab5d33557fa3d49a7efede792
|
4
|
+
data.tar.gz: 59ec164cf8865491cf0e4c59628d62ce5a9a0dd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a12ea012f3a6b64322a8542dc21af3cc6ad2c5774c7a632246b429ca0bcfa212c0c9d8ce8925210e403284c612fff5ac037c084e02b297b4439bc75cc6d99ec5
|
7
|
+
data.tar.gz: a9bc5d3679d9ca6925f2e6b45e1961fa879865978b0f10a25edf41b4eda101515393ff10f420996b7796ec50c9ad91c0cf8ebee0665153867e729fc1adbd27f6
|
@@ -34,6 +34,7 @@ module Elasticsearch
|
|
34
34
|
@hosts = arguments[:hosts] || []
|
35
35
|
@options = arguments[:options] || {}
|
36
36
|
@options[:http] ||= {}
|
37
|
+
@options[:retry_on_status] ||= []
|
37
38
|
|
38
39
|
@block = block
|
39
40
|
@connections = __build_connections
|
@@ -268,7 +269,6 @@ module Elasticsearch
|
|
268
269
|
rescue Elasticsearch::Transport::Transport::ServerError => e
|
269
270
|
if @retry_on_status.include?(response.status)
|
270
271
|
logger.warn "[#{e.class}] Attempt #{tries} to get response from #{url}" if logger
|
271
|
-
logger.debug "[#{e.class}] Attempt #{tries} to get response from #{url}" if logger
|
272
272
|
if tries <= max_retries
|
273
273
|
retry
|
274
274
|
else
|
@@ -312,16 +312,17 @@ module Elasticsearch
|
|
312
312
|
if response.status.to_i >= 300
|
313
313
|
__log method, path, params, body, url, response, nil, 'N/A', duration if logger
|
314
314
|
__trace method, path, params, body, url, response, nil, 'N/A', duration if tracer
|
315
|
-
__log_failed response if logger
|
316
315
|
|
317
|
-
#
|
316
|
+
# Log the failure only when `ignore` doesn't match the response status
|
317
|
+
__log_failed response if logger && !ignore.include?(response.status.to_i)
|
318
|
+
|
318
319
|
__raise_transport_error response unless ignore.include?(response.status.to_i)
|
319
320
|
end
|
320
321
|
|
321
322
|
json = serializer.load(response.body) if response.body && !response.body.empty? && response.headers && response.headers["content-type"] =~ /json/
|
322
323
|
took = (json['took'] ? sprintf('%.3fs', json['took']/1000.0) : 'n/a') rescue 'n/a' if logger || tracer
|
323
324
|
|
324
|
-
__log method, path, params, body, url, response, json, took, duration if logger
|
325
|
+
__log method, path, params, body, url, response, json, took, duration if logger && !ignore.include?(response.status.to_i)
|
325
326
|
__trace method, path, params, body, url, response, json, took, duration if tracer
|
326
327
|
|
327
328
|
Response.new response.status, json || response.body, response.headers
|
@@ -167,8 +167,12 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
167
167
|
logger: (ENV['QUIET'] ? nil : @logger),
|
168
168
|
retry_on_status: 400
|
169
169
|
|
170
|
+
# Set the logger when the `QUIET` option is set
|
171
|
+
@client.transport.logger ||= Logger.new(STDERR)
|
172
|
+
|
173
|
+
@client.transport.logger.stubs(:fatal)
|
170
174
|
@client.transport.logger
|
171
|
-
.expects(:
|
175
|
+
.expects(:warn)
|
172
176
|
.with( regexp_matches(/Attempt \d to get response/) )
|
173
177
|
.times(4)
|
174
178
|
|
@@ -181,7 +185,9 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
181
185
|
context "when reloading connections" do
|
182
186
|
should "keep existing connections" do
|
183
187
|
require 'patron' # We need a client with keep-alive
|
184
|
-
client = Elasticsearch::Transport::Client.new host: "127.0.0.1:#{@port}",
|
188
|
+
client = Elasticsearch::Transport::Client.new host: "127.0.0.1:#{@port}",
|
189
|
+
adapter: :patron,
|
190
|
+
logger: (ENV['QUIET'] ? nil : @logger)
|
185
191
|
|
186
192
|
assert_equal 'Faraday::Adapter::Patron',
|
187
193
|
client.transport.connections.first.connection.builder.handlers.first.name
|
@@ -420,7 +420,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
|
|
420
420
|
@transport.perform_request('GET', '/') {Elasticsearch::Transport::Transport::Response.new 200, '{"foo":"bar"}' }
|
421
421
|
end
|
422
422
|
|
423
|
-
should "log a failed Elasticsearch request" do
|
423
|
+
should "log a failed Elasticsearch request as fatal" do
|
424
424
|
@block = Proc.new { |c, u| puts "ERROR" }
|
425
425
|
@block.expects(:call).returns(Elasticsearch::Transport::Transport::Response.new 500, 'ERROR')
|
426
426
|
|
@@ -432,6 +432,17 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
|
|
432
432
|
end
|
433
433
|
end unless RUBY_1_8
|
434
434
|
|
435
|
+
should "not log a failed Elasticsearch request as fatal" do
|
436
|
+
@block = Proc.new { |c, u| puts "ERROR" }
|
437
|
+
@block.expects(:call).returns(Elasticsearch::Transport::Transport::Response.new 500, 'ERROR')
|
438
|
+
|
439
|
+
@transport.expects(:__log).once
|
440
|
+
@transport.logger.expects(:fatal).never
|
441
|
+
|
442
|
+
# No `BadRequest` error
|
443
|
+
@transport.perform_request('POST', '_search', :ignore => 500, &@block)
|
444
|
+
end unless RUBY_1_8
|
445
|
+
|
435
446
|
should "log and re-raise a Ruby exception" do
|
436
447
|
@block = Proc.new { |c, u| puts "ERROR" }
|
437
448
|
@block.expects(:call).raises(Exception)
|
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: 5.0.
|
4
|
+
version: 5.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -332,8 +332,24 @@ dependencies:
|
|
332
332
|
- - ">="
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: '0'
|
335
|
-
|
336
|
-
|
335
|
+
- !ruby/object:Gem::Dependency
|
336
|
+
name: test-unit
|
337
|
+
requirement: !ruby/object:Gem::Requirement
|
338
|
+
requirements:
|
339
|
+
- - "~>"
|
340
|
+
- !ruby/object:Gem::Version
|
341
|
+
version: '2'
|
342
|
+
type: :development
|
343
|
+
prerelease: false
|
344
|
+
version_requirements: !ruby/object:Gem::Requirement
|
345
|
+
requirements:
|
346
|
+
- - "~>"
|
347
|
+
- !ruby/object:Gem::Version
|
348
|
+
version: '2'
|
349
|
+
description: 'Ruby client for Elasticsearch. See the `elasticsearch` gem for full
|
350
|
+
integration.
|
351
|
+
|
352
|
+
'
|
337
353
|
email:
|
338
354
|
- karel.minarik@elasticsearch.org
|
339
355
|
executables: []
|
@@ -399,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
415
|
version: '0'
|
400
416
|
requirements: []
|
401
417
|
rubyforge_project:
|
402
|
-
rubygems_version: 2.
|
418
|
+
rubygems_version: 2.6.10
|
403
419
|
signing_key:
|
404
420
|
specification_version: 4
|
405
421
|
summary: Ruby client for Elasticsearch.
|