elasticsearch-transport 5.0.0 → 5.0.1

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: 8c3784ade70a4f287b4e121b2498e9cd36c693ba
4
- data.tar.gz: 83d63462da4185255e095f975aa5be874bd0f6d3
3
+ metadata.gz: 2b270a67bd3d6c3566fb5503a86965472087c5ef
4
+ data.tar.gz: 629cce04c30b1968ce0d7fab0e4347cd99b70bda
5
5
  SHA512:
6
- metadata.gz: 27a8f8fbde68ca78613400b7b885f96724ed65865afe06ec07ffafa77c6efe3fd66fa3eebbf385873ae4fcf1eadd8396a7b5d2555514719e456710efe6a916b9
7
- data.tar.gz: 230ef52cf57b3d629c10c31a0e0d74eb645c2de88b7397819b75b5dabdc92de1778144097e9fbd1e18cef17cba616ba297c72bb08843df9c921075f41e1a15a4
6
+ metadata.gz: 5849da863dfc15089eb5f443c9364cdbe476cebc8e02b9db89d95c5c225622b694fd40e3fedc71c18f94e8a62702c099ade7931a708cd271481c47dbb02b910c
7
+ data.tar.gz: e3824c7169dfdc5061fb4b1dd2e4ad0919cc9ac33180c1c3220027ea08e92c0ee8224cad3e0ea128f76da14757a21c8eec97b469eb949c3b5191165b8acc3551
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ if File.exist? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemsp
7
7
  gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
8
8
  end
9
9
 
10
- if File.exist? File.expand_path("../../elasticsearch-extensions", __FILE__)
10
+ if File.exist? File.expand_path("../../elasticsearch-extensions/elasticsearch-extensions.gemspec", __FILE__)
11
11
  gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => false
12
12
  end
13
13
 
@@ -49,9 +49,9 @@ module Elasticsearch
49
49
  @counter_mtx = Mutex.new
50
50
  @last_request_at = Time.now
51
51
  @reload_connections = options[:reload_connections]
52
- @reload_after = options[:reload_connections].is_a?(Fixnum) ? options[:reload_connections] : DEFAULT_RELOAD_AFTER
52
+ @reload_after = options[:reload_connections].is_a?(Integer) ? options[:reload_connections] : DEFAULT_RELOAD_AFTER
53
53
  @resurrect_after = options[:resurrect_after] || DEFAULT_RESURRECT_AFTER
54
- @max_retries = options[:retry_on_failure].is_a?(Fixnum) ? options[:retry_on_failure] : DEFAULT_MAX_RETRIES
54
+ @max_retries = options[:retry_on_failure].is_a?(Integer) ? options[:retry_on_failure] : DEFAULT_MAX_RETRIES
55
55
  @retry_on_status = Array(options[:retry_on_status]).map { |d| d.to_i }
56
56
  end
57
57
 
@@ -244,6 +244,10 @@ module Elasticsearch
244
244
  start = Time.now if logger || tracer
245
245
  tries = 0
246
246
 
247
+ params = params.clone
248
+
249
+ ignore = Array(params.delete(:ignore)).compact.map { |s| s.to_i }
250
+
247
251
  begin
248
252
  tries += 1
249
253
  connection = get_connection or raise Error.new("Cannot get new connection from pool.")
@@ -309,7 +313,9 @@ module Elasticsearch
309
313
  __log method, path, params, body, url, response, nil, 'N/A', duration if logger
310
314
  __trace method, path, params, body, url, response, nil, 'N/A', duration if tracer
311
315
  __log_failed response if logger
312
- __raise_transport_error response
316
+
317
+ # Swallow the exception when the `ignore` parameter matches response status
318
+ __raise_transport_error response unless ignore.include?(response.status.to_i)
313
319
  end
314
320
 
315
321
  json = serializer.load(response.body) if response.body && !response.body.empty? && response.headers && response.headers["content-type"] =~ /json/
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Transport
3
- VERSION = "5.0.0"
3
+ VERSION = "5.0.1"
4
4
  end
5
5
  end
@@ -53,6 +53,14 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
53
53
  end
54
54
  end
55
55
 
56
+ should "ignore specified response codes" do
57
+ response = @client.perform_request 'GET', '/_foobar', ignore: 400
58
+ assert_equal 400, response.status
59
+
60
+ assert_instance_of Hash, response.body
61
+ assert_match /illegal_argument_exception/, response.body.inspect
62
+ end
63
+
56
64
  should "pass options to the transport" do
57
65
  @client = Elasticsearch::Client.new \
58
66
  host: "127.0.0.1:#{@port}",
@@ -246,6 +246,21 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
246
246
  end
247
247
  end
248
248
 
249
+ should "not raise an error when the :ignore argument has been passed" do
250
+ @transport.stubs(:get_connection).returns(stub_everything :failures => 1)
251
+
252
+ assert_raise Elasticsearch::Transport::Transport::Errors::BadRequest do
253
+ @transport.perform_request 'GET', '/' do
254
+ Elasticsearch::Transport::Transport::Response.new 400, 'CLIENT ERROR'
255
+ end
256
+ end
257
+
258
+ # No `BadRequest` error
259
+ @transport.perform_request 'GET', '/', :ignore => 400 do
260
+ Elasticsearch::Transport::Transport::Response.new 400, 'CLIENT ERROR'
261
+ end
262
+ end
263
+
249
264
  should "mark the connection as dead on failure" do
250
265
  c = stub_everything :failures => 1
251
266
  @transport.expects(:get_connection).returns(c)
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.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-07 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json